[R] additional axis, different scale
pannigh
pannigh at gwdg.de
Thu May 10 13:37:37 CEST 2012
Dear list,
I am looking for a possibility to present results in a more graphical way by
adding an axis. But I have trouble relating my data to the added axis.
Imagine the following example:
a <- c(10, 20, 30, 40)
b <- c(50, 250, 500, 600)
ba <- b/a
par(las=1, mar=c(5,5,.5,5))
plot(a,b, type="b", pch=22, cex=2, col=4, lwd=2, ylim=c(0,650),
xlim=c(0,45))
axis(4, at=c(seq(0,600,length=6)), lab=c(seq(0,25,length=6)), col.axis=2 )
lines(a,ba, type="b", pch=21, cex=2, col=2, lwd=2, lty=1)
I want the red line to relate its values to the x-axis (a) and axis 4 (on
the right) and not as usual to the x-axis (a) and the y-axis (b).
This would show the tendency of the red line much clearer which now can't be
seen because of the very different scaling.
E.g. I want R to know that I am trying to plot the first point of the red
line P1(50/5) using the x-axis and the right axis, not the y-axis on the
left ect.
I would like to solve this without using a factor solution like:
bb <-600/25 * ba
lines(a,bb, type="b", pch=21, cex=2, col=3, lwd=2, lty=1)
For any kind of help I would be grateful !
--
View this message in context: http://r.789695.n4.nabble.com/additional-axis-different-scale-tp4623210.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list