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
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, > CaoYou 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. HTH, Marc Schwartz
Hi. set a ylim equal to the max of your data: #create test data x1 <- x2 <-x3 <-(1:10) y1 <-runif(10)/2 #to get a low maximum y1 y2 <-runif(10) y3 <-runif(10) #plot as you did plot(x=x1,y=y1,type="l") #y-axis is not big enough lines(x=x2,y=y2) lines(x=x3,y=y3) #plot with minimum/maximum y limit plot(x=x1,y=y1,type="l",ylim=c(min(y1,y2,y2),max(y1,y2,y2))) #fixed lines(x=x2,y=y2) lines(x=x3,y=y3) Neuro>From: Baoqiang Cao <caobg at email.uc.edu> >Reply-To: caobg at email.uc.edu >To: R-help at stat.math.ethz.ch >Subject: [R] help on ploting various lines >Date: Wed, 21 Jun 2006 12:22:16 -0400 (EDT) > >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 > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! >http://www.R-project.org/posting-guide.html
Sorry, had two y2 in the min/max ylim plot(x=x1,y=y1,type="l",ylim=c(min(y1,y2,y3),max(y1,y2,y3))) #fixed lines(x=x2,y=y2) lines(x=x3,y=y3)>From: Baoqiang Cao <caobg at email.uc.edu> >Reply-To: caobg at email.uc.edu >To: R-help at stat.math.ethz.ch >Subject: [R] help on ploting various lines >Date: Wed, 21 Jun 2006 12:22:16 -0400 (EDT) > >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 > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! >http://www.R-project.org/posting-guide.html