[R] changing the limits of a secondary y-axis in a barplot

Mark Difford mark_difford at yahoo.co.uk
Wed Nov 17 09:31:52 CET 2010


Hi Anna,

>> How can I change the barplot so that the left hand axis scales from 0 to
>> 15 and the right hand 
>> axis from 0 to 5?

Try this:

par(mfrow=c(1,1), mai=c(1.0,1.0,1.0,1.0))
Plot1<-barplot(rbind(Y1,Y2), beside=T, axes=T, names.arg=c("a","b"),
ylim=c(0,15), xlim=c(1,9), space=c(0,1), col=c("darkgray","white"),
yaxt="n")
Plot2<-barplot(Y3, add=T, beside=T, names.arg="c",
col=c("darkgray","white"), ylim=c(0,5), space=c(0,7), width=1, yaxt="n")
axis(side=2, at=seq(0,15,3), labels=seq(0,15,3))
axis(side=4, at=seq(0,15,3), labels=seq(0,5,1))

Regards, Mark.
-- 
View this message in context: http://r.789695.n4.nabble.com/changing-the-limits-of-a-secondary-y-axis-in-a-barplot-tp3046117p3046283.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list