Big Data/Analytics Zone is brought to you in partnership with:

Rob Hyndman is a Professor of Statistics at Monash University, Australia. He is Editor-in-Chief of the International Journal of Forecasting and author of over 100 research papers in statistical science. He also maintains an active consulting practice, assisting hundreds of companies and organizations. His recent consulting work has involved forecasting electricity demand, tourism demand, the Australian government health budget and case volume at a US call centre. Rob J is a DZone MVB and is not an employee of DZone and has posted 46 posts at DZone. You can read more from them at their website. View Full User Profile

An R Graph with Two Y-Axes

  • submit to reddit

I’ve been asked how to do this sev­eral times, so I thought it might help to put an exam­ple online.

x <- 1:5
y1 <- rnorm(5)
y2 <- rnorm(5,20)
plot(x, y2,,type="l",col="blue",xaxt="n",yaxt="n",xlab="",ylab="")


Published at DZone with permission of Rob J Hyndman, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)