[R] r: plots
HankeA at mar.dfo-mpo.gc.ca
Tue Feb 24 16:04:28 CET 2004
z<-c(0.001, 0.15, 0.6, 0.8, 1)
axis(4, at=seq(0,1,.1), labels=seq(0,1,.1))
> -----Original Message-----
> From: Duncan Murdoch [SMTP:dmurdoch at pair.com]
> Sent: Tuesday, February 24, 2004 6:10 AM
> To: allan clark
> Cc: Rhelp
> Subject: Re: [R] r: plots
> On Tue, 24 Feb 2004 14:44:47 +0200, allan clark
> <allan at stats.uct.ac.za> wrote :
> >hi all
> >i have another probably simple question.
> >I have three variables say x, y and z. x and y are quite large and z is
> >relative small.
> >how can one plot the three variables on the same graph with two separate
> >(one for x and y and the other for z)
> >z<-c(0.001, 0.15, 0.6, 0.8, 1)
> You need to do most of the work yourself:
> par(mar=par('mar')+c(0,0,0,2)) # make room for the extra axis
> plot(1:5, x, ylim = c(0, 200)) # plot x with room for the others
> points(1:5, y, pch=2) # plot y
> points(1:5, 200*z, pch=3) # plot z, magnified 200 times
> zticks <- pretty(z) # choose ticks for z
> axis(4, at=200*zticks, labels=zticks) # plot them
> mtext('z',side=4, line=3) # add the z label
> You'll also want to add a legend, but I'll let you figure that out.
> Duncan Murdoch
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide!
More information about the R-help