Superimpose two graphs
On 11/28/2011 05:46 PM, Vikram Bahure wrote:
Dear R users, I want to superimpose two graphs as well as ensure that they should have same scale with same x& y axis. I am using following command but it does not ensure same scale. *pdf(file = "../RESULTS/RS1.simulated.pdf", width = 10, height =6)* *plot(Reserves.RS, col = 1:2, screen = 1)* *par(new= TRUE)* *barplot(RS.active, axes = FALSE)* *dev.off()* * *
Hi Vikram,
Try this:
library(plotrix)
ylim<-range(c(Reserves.RS,RS.active))
twoord.plot(ly=RS.active,ry=Reserves.RS,rcol=1,type=c("bar","p"),
lylim=ylim,rylim=ylim)
I'm assuming that you have the same number of values in each vector, if
not, you may have to specify xlim as well.
Jim