Re: [R] help on ploting various lines

2006-06-21 Thread Baoqiang Cao
Thank you very much Marc Schwartz and Neuro LeSuperHéros! At last I got what I 
expected, of course, with help of your messages. What a great day!

Best,
 Cao

__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] help on ploting various lines

2006-06-21 Thread Neuro LeSuperHéros
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 <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [email protected]
>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
>
>__
>[email protected] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! 
>http://www.R-project.org/posting-guide.html

__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] help on ploting various lines

2006-06-21 Thread Neuro LeSuperHéros
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 <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [email protected]
>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
>
>__
>[email protected] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! 
>http://www.R-project.org/posting-guide.html

__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] help on ploting various lines

2006-06-21 Thread Marc Schwartz (via MN)
On Wed, 2006-06-21 at 11:55 -0500, Marc Schwartz (via MN) wrote:
> 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.

One other note, which is to review:

  ?matplot

which also has help for matpoints() and matlines(), which will do the
common axis range adjustments for you. 

This will be helpful if you are going to be plotting a larger number of
points/lines in a single graphic.

HTH,

Marc

__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] help on ploting various lines

2006-06-21 Thread Marc Schwartz (via MN)
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.

HTH,

Marc Schwartz

__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html