[R] plot

Morten Sickel Morten.Sickel at nrpa.no
Mon Mar 17 09:06:30 CET 2003


noliveir2003 at zipmail.com.br [mailto:noliveir2003 at zipmail.com.br] wrote:

>Can anyone tell me how to plot on the same graph two different functions
>(of x) using two differnt y scales (axes 2 and 4)?

The only way I've found is to use the grid library and push.viewport(). 
((...) means substitute with whatever appropriate, use help())

library(grid)
grid.newpage()
push.viewport(viewport(yscale=c(0,500),w=.75,h=.75,xscale=c(0:100)))
grid.poins(...) # Plots data point with an y-scale of 0-500
grid.xaxis(...)
grid.yaxis(...) # Draws the left y-axis
push.viewport(viewport(yscale=c(0,10),xscale=c(0:100)))
grid.poins(...) # Plots data point with an y-scale of 0-10
grid,yaxis(main=FALSE,...) # Draws the right y-axis

Morten

-- 
Morten Sickel
Norwegian Radiation Protection Authority
http://www.nrpa.no



More information about the R-help mailing list