Monday, April 8, 2013

RG#37: XY line or scatter plot graph with two Y axis

# data
set.seed(1234)
x <- 1:20
y1 <- rnorm(20, 5, 1)
y2 <- rnorm(20,20, 2)

y3 <- rnorm(20,5, 3)



# plot
par(mar=c(5,4,4,5)+.1)
plot(x,y1,type="l",col="red", ylab = "Y1/Y3")

points (x,y3, col = "green4", pch = 19)

par(new=TRUE)
plot(x, y2, type="l",col="blue",xaxt="n",yaxt="n",xlab="",ylab="")

axis(4)
mtext("y2",side=4,line=3)

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.