saurabh_koparkar
2009-Jan-18 16:12 UTC
[R] Formatting the axis of plot() to shown our own values.
Part 1: I want to plot the CO2 concentration vs. year, but extending the x-axis using the xlim parameter to include the year 2006 (x axis range of values are from -41210 to 0), and adjusting the ylim parameter to go up to 400 when the range of y axis values are from 150 to 300. How do I do this? Using axis function? I am confused about the syntax here. Part 2: I also want to use the points() function to add the data points from years 1958-2006 on X axis to the above plot, but in a different color. Please help. Thanks, Saurabh -- View this message in context: http://www.nabble.com/Formatting-the-axis-of-plot%28%29-to-shown-our-own-values.-tp21529473p21529473.html Sent from the R help mailing list archive at Nabble.com.
Stephan Kolassa
2009-Jan-18 19:35 UTC
[R] Formatting the axis of plot() to shown our own values.
Hi Saurabh saurabh_koparkar schrieb:> Part 1: > I want to plot the CO2 concentration vs. year, but extending the x-axis > using the xlim parameter to include the year 2006 (x axis range of values > are from -41210 to 0), and adjusting the ylim parameter to go up to 400 when > the range of y axis values are from 150 to 300. How do I do this? Using axis > function? I am confused about the syntax here.plot(year,co2,xlim=c(-41210,2006),ylim=c(150,400))> Part 2: > I also want to use the points() function to add the data points from years > 1958-2006 on X axis to the above plot, but in a different color.points(...,...,bg="red") Perhaps also col="red" - may depend on what character (pch=..) you are plotting. HTH, Stephan
Rau, Roland
2009-Jan-18 19:50 UTC
[R] Formatting the axis of plot() to shown our own values.
Hi -----Original Message----- From: r-help-bounces@r-project.org on behalf of saurabh_koparkar Sent: Sun 1/18/2009 5:12 PM To: r-help@r-project.org Subject: [R] Formatting the axis of plot() to shown our own values. Part 1: I want to plot the CO2 concentration vs. year, but extending the x-axis using the xlim parameter to include the year 2006 (x axis range of values are from -41210 to 0), and adjusting the ylim parameter to go up to 400 when the range of y axis values are from 150 to 300. How do I do this? Using axis function? I am confused about the syntax here. Try this: data(co2) plot(co2, xlim=c(1958,2007), ylim=c(300,400), xlab="Time", ylab=expression(CO[2]), col="blue", axes=FALSE) axis(side=1, at=seq(1960, 2000, by=10), pos=300) axis(side=2, at=c(300,333,350,400), pos=1958) Part 2: I also want to use the points() function to add the data points from years 1958-2006 on X axis to the above plot, but in a different color. Not sure what you want exactly, but I hope this is what you want: data(co2) plot(co2, xlim=c(1958,2007), ylim=c(300,400), xlab="Time", ylab=expression(CO[2]), col="blue", axes=FALSE) axis(side=1, at=seq(1960, 2000, by=10), pos=300) axis(side=2, at=c(300,333,350,400), pos=1958) points(co2, col="red") Hope this helps, Roland ---------- This mail has been sent through the MPI for Demographic ...{{dropped:10}}