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}}


