[R] Two plots with two different Y labels
d.rizopoulos at erasmusmc.nl
Thu Mar 1 09:32:42 CET 2012
x <- 1:5
y1 <- rnorm(5)
y2 <- rnorm(5)
par(mar = c(5,4,5,4))
plot(x, y1, xlab = "x-axis", ylab = "y-axis", type = "l")
par(new = TRUE)
plot(x, y2, axes = FALSE, yaxs = "i", type = "l",
ann = FALSE, col = 2)
axis(4, las = 2)
mtext("z-axis", 4, 2)
I hope it helps.
On 3/1/2012 9:13 AM, Alaios wrote:
> Dear all,
> I would like to place into a same plot two plots. Their y values though are different a lot (first series has around -100 y values and the second one slightly over 1). The x value are the same.
> I would like to have in the same plot (under the same x,y axis the two plots). Is it possible then to have two y labels, one for example in the left side and an extra y label at the right. Each y label will have its own labeling and its own Font type line.
> CAn I do something like that in R with the normal plots and lines?
> I would like to thank you in advance for your help
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
More information about the R-help