Re: [R] More Plots

From: tristan rouyer <tristan.rouyer_at_ifremer.fr>
Date: Wed 09 Aug 2006 - 02:54:34 EST

sonal@deepfoo.com a écrit :
> Hi,
>
> How can we plot two graphs ex. lets say correlation & ratio in the same
> window?
>
> I mean in the window I have :
>
> 1. Graph of correlation having X & Y axes
>
> 2. Graph of ratio having A & B axes
>
> one above the other.
>
> Thanks,
> Sonal
>
> ______________________________________________
> R-help@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
> and provide commented, minimal, self-contained, reproducible code.
>
Hi,
you can simply do that using the command par(new=TRUE) between your two graphs.
example :
x<-rnorm(100,0,2)
y<-2*x+rnorm(100,0,2)
plot(y~x)
par(new=TRUE)
z<-rnorm(100,10,2)
plot(z,col='red')

As you can notice the second plot is roughly added to the new one, even if the scales are different. So you basically have to specify the axes of the second plot, using the axis() command (after specifying xaxt='n' and yaxt='n' in the second plot for removing its axes).

Tristan



R-help@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 and provide commented, minimal, self-contained, reproducible code. Received on Wed Aug 09 02:59:36 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 09 Aug 2006 - 04:18:56 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.