[R] ylab at the right hand of a plot with two y axes

From: Young Cho <young.stat_at_gmail.com>
Date: Tue, 26 Jun 2007 09:29:05 -0700


When I try to plot two lines ( or scatterplots) with different scales, this is what I have been doing:

Suppose: I have y1 and y2 in a very different scale

y1 = 1:100
y2 = c(100:1)*10

To plot them on top of each other and denote by different colors: I have to figure out the correct scale '10' and corresponding tick.vector and lables. Then do:

plot(1:100, y1) # I can have 'ylab' here for the left-hand side y axis. points(1:100, y2/10,col=2)
ytick.vector = seq(from=0,to=100,by=20)
ytick.label = as.character(seq(from=0,to=1000,by=200)) axis(4,at = ytick.vector,label = ytick.label,col=2,col.axis=2)

Two questions.

  1. Are there easier ways to plot the y1, y2 w/o figuring out the correct scaler, tick vectors, and labels in order to put them in one figure?
  2. How to add additional 'ylab' to the right hand side y-axis of the plot? Thanks a lot!

-Young

        [[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. Received on Tue 26 Jun 2007 - 16:54:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 26 Jun 2007 - 22:32:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.