[R] Plot with two seperate y axis

Jim Lemon jim at bitwrit.com.au
Sun Nov 26 11:21:11 CET 2006


Thorsten Muehge wrote:
> Hello,
> I would like to plot the following matrix:
> Wk=x achsis.
> Para 1 = left y-axis as a barplot
> para 2 right y-axis as a normal scatter plat.
> 
> I could not find such a solution in any of my documentation.
> 
> Can someone help me?
> 
> Thanks a lot
> Thorsten
> 
> Wk    Para 1      Para 2
> 31    2000  99.8
> 32    2005  99.0
> 33    2002  98.0
> 34    1090  98.5
> 35    2001  99.1
> 36    2010  97.0
> 37    2010  98.8
> 
Hi Thorsten,

Is this what you mean?

par(mar=c(5,4,4,4))
xpos<-barplot(mueghe.df$Para.1)
axis(1,at=xpos,labels=mueghe.df$Wk)
par(new=TRUE)
plot(xpos,mueghe.df$Para.2,xlim=par("usr")[1:2],xaxs="i",
  ylim=c(0,100),type="n",xlab="",ylab="",axes=FALSE)
axis(4)
points(xpos,mueghe.df$Para.2)

Jim



More information about the R-help mailing list