[R] Plot with two seperate y axis

David Barron mothsailor at googlemail.com
Fri Nov 24 14:44:23 CET 2006


Assuming the data are in a data frame called dt, this should work:

> plot(dt$Wk,dt$Para1,type="h")
> par(new=TRUE)
> plot(dt$Wk,dt$Para2,yaxt="n")
> axis(4,at=97:100)


On 24/11/06, Thorsten Muehge <MUEHGE at de.ibm.com> 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
>
> ______________________________________________
> 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.
>


-- 
=================================
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP



More information about the R-help mailing list