Usually the y-axis is shown on the left-hand-side of a graph, is it possible to artifically creat one more y-axis on the right-hand-side in R? What is the main reference? Thank you in advance. [[alternative HTML version deleted]]
Look at: ?axis (try the examples) Further, a nice example I found on this mailing lists archive, from somebody who says this has been asked many times already :) x <- 1:10 y1 <- 1:10 y2 <- rev(seq(1,1000, length=10)) plot(x,y1,ann=FALSE) axis(2, at=c(2,4,6,8), labels=as.character(c(2,4,6,8))) points(x,y2/100,col="red") axis(4, at=c(2,4,6,8), labels=as.character(c(200, 400, 600, 800))) On Wed, 06 Sep 2006 18:10:33 +0800, gallon li wrote:> Usually the y-axis is shown on the left-hand-side of a graph, is it > possible to artifically creat one more y-axis on the right-hand-side in R? > What is the main reference? Thank you in advance. > > [[alternative HTML version deleted]] > > ______________________________________________ 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.
---------- Forwarded message ---------- From: gallon li <gallon.li@gmail.com> Date: Sep 6, 2006 7:48 PM Subject: Re: [R] plot axises on both sides of a graph To: Jim Lemon <jim@bitwrit.com.au> Both of your suggestions are so helpful. By combining what you told me, now I am able to produce a second y-axis on the right-hand-side. Still one problem remains: how can I put a definition of this y-axis in the space left? Clearly there is enough room and I have to check some functions for defining the margin of a plot. Moreoever, it seems not straight forward to put some vertical text directly on the plot for this second ylab. On 9/7/06, Jim Lemon <jim@bitwrit.com.au> wrote:> > gallon li wrote: > > Usually the y-axis is shown on the left-hand-side of a graph, is it > possible > > to artifically creat one more y-axis on the right-hand-side in R? What > is > > the main reference? Thank you in advance. > > > Have a look at: > > http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_addat.html > > Jim >[[alternative HTML version deleted]]
See these two examples.
plot(1:2)
axis(4)
mtext("right y axis", side=4, line=-1.5)
par(mar=c(5,4,4,5)+.1)
plot(1:2)
axis(4)
mtext("right y axis", side=4, line=3)
Good luck finding the right combination again ;)
On Wed, 06 Sep 2006 20:08:43 +0800, gallon li wrote:
> ---------- Forwarded message ---------- From: gallon li
> <gallon.li at gmail.com> Date: Sep 6, 2006 7:48 PM
> Subject: Re: [R] plot axises on both sides of a graph To: Jim Lemon
> <jim at bitwrit.com.au>
>
> Both of your suggestions are so helpful. By combining what you told me,
> now I am able to produce a second y-axis on the right-hand-side. Still one
> problem remains: how can I put a definition of this y-axis in the space
> left? Clearly there is enough room and I have to check some functions for
> defining the margin of a plot. Moreoever, it seems not straight forward to
> put some vertical text directly on the plot for this second ylab.