[R] How to plot graph with different scale (y axis) on same graph?
ghostwheel
lachmann at eva.mpg.de
Thu Apr 26 12:35:29 CEST 2012
You ask two questions. First, how to put points with a different y-axis on
the plot.
One possibility s like this:
> plot(1:10)
> plot.window(xlim=c(1,10),ylim=c(1,100))
> points( seq(1,10,length=100), 100:1, col=2 )
> axis(4,col.axis=2,col=2)
The command plot.window is the one that changes the range for ylim.
The second question is about plotting 5 million data points.
Since it is very hard to really take in 5 million data points, I'd subsample
the plot, so do
x=1:5e6
y=x^2
i=sample( seq( along=y ), 1e4 )
plot( x,[i], y[i] , pch=".")
If you do plot 5 million points, I'd plot them on a raster device, like png.
In if you plot them in pdf or postscript, printing/viewing the result will
take a long time.
So do something like
png("bigplot.png")
plot(x,y,pch=".")
--
View this message in context: http://r.789695.n4.nabble.com/How-to-plot-graph-with-different-scale-y-axis-on-same-graph-tp4589364p4589416.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list