[R] help on ploting various lines

Marc Schwartz (via MN) mschwartz at mn.rr.com
Wed Jun 21 18:55:18 CEST 2006

On Wed, 2006-06-21 at 12:22 -0400, Baoqiang Cao wrote:
> Dear All,
> I tried to plot a variety of lines(curves) on same figure. What I did
> is,
> plot(x=x1,y=y1)
> lines(x=x2,y=y2)
> lines(x=x3,y=y3)
> ...
> In my data, the maximum of y1 is much smaller than those maximums of
> other y vectors. So, in the figure I got, there are some curves which
> are not complete, I mean, they were cut off at the maximum of y1 at
> the y axis. Could anybody point out some right commands I need use?
> Thanks!
> Best,
>  Cao

You will want to use the 'xlim' and 'ylim' arguments in plot() to set
the initial axis ranges for the scatter plot based upon the ranges of
the combined x* or y* vectors. That way, the plot region ranges are set
to include all of your values.

x.range <- range(x1, x2, x3)
y.range <- range(y1, y2, y3)

plot(x1, y1, xlim = x.range, ylim = y.range)
lines(x2, y2)
lines(x3, y3)

See ?plot.default for more information.


Marc Schwartz

More information about the R-help mailing list