[R] More Plots
tristan rouyer
tristan.rouyer at ifremer.fr
Tue Aug 8 18:54:34 CEST 2006
sonal at 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 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
> 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
More information about the R-help
mailing list