Hello, When I plot any data with simple plot command in R, for example :- plot(time,co2,ylim=c(350,380),xlim=c(1993,2003),xlab=NA,ylab=NA,type="p",col=5) Then the first value of x-axis(350) and y-axis(1993) never starts from origin, always they sifted from the origin. Is there any command that I can correct this in the ploted figure and both the axis values start from origin. Thanks for help, Regards, Yogesh -- ==========================================Yogesh K. Tiwari, Max-Planck Institute for Biogeochemistry, Beutenberg Campus, Hans-Knoell-Strasse 10, D-07745 Jena, Germany Office : 0049 3641 576 376 Home : 0049 3641 223 163 Fax : 0049 3641 577 300 Cell : 0049 1520 4591 008 e-mail : yogesh.tiwari at bgc-jena.mpg.de
?par look at xaxs. Or just read `An Introduction to R' more carefully! On Fri, 1 Apr 2005, Yogesh K. Tiwari wrote:> Hello, > > When I plot any data with simple plot command in R, for example :- > > plot(time,co2,ylim=c(350,380),xlim=c(1993,2003),xlab=NA,ylab=NA,type="p",col=5) > > Then the first value of x-axis(350) and y-axis(1993) never starts from > origin, always they sifted from the origin. Is there any command that I can > correct this in the ploted figure and both the axis values start from origin.-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
> From: Yogesh K. Tiwari > > Hello, > > When I plot any data with simple plot command in > R, for example :- > > plot(time,co2,ylim=c(350,380),xlim=c(1993,2003),xlab=NA,ylab=N > A,type="p",col=5) ^^^^^^^^^^^^^^^^^R can only do what you _ask_ it to do, not what you want it to do. You have explicitly tell R to limit the range of the x-axis to 1993 and 2003. If you want to include the origin (0, 0), use 0 as the lower limit in both ylim and xlim. Andy> Then the first value of x-axis(350) and > y-axis(1993) never starts from origin, always they > sifted from the origin. Is there any command that > I can correct this in the ploted figure and both > the axis values start from origin. > > Thanks for help, > > Regards, > Yogesh > > > -- > > ==========================================> Yogesh K. Tiwari, > Max-Planck Institute for Biogeochemistry, > Beutenberg Campus, Hans-Knoell-Strasse 10, > D-07745 Jena, > Germany > > Office : 0049 3641 576 376 > Home : 0049 3641 223 163 > Fax : 0049 3641 577 300 > Cell : 0049 1520 4591 008 > e-mail : yogesh.tiwari at bgc-jena.mpg.de > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > >
On Fri, 2005-04-01 at 18:13 +0200, Yogesh K. Tiwari wrote:> Hello, > > When I plot any data with simple plot command in > R, for example :- > > plot(time,co2,ylim=c(350,380),xlim=c(1993,2003),xlab=NA,ylab=NA,type="p",col=5) > > Then the first value of x-axis(350) and > y-axis(1993) never starts from origin, always they > sifted from the origin. Is there any command that > I can correct this in the ploted figure and both > the axis values start from origin. > > Thanks for help, > > Regards, > YogeshIf I understand you correctly, you need to specify the axis "style". By default, R expands the axis ranges by 4% in both directions. This is defined by par("xaxs") and par("yaxs"), where both are set to "r". You need to set both to "i". Thus: plot(time, co2, ylim = c(350, 380), xlim = c(1993, 2003), xlab = NA, ylab = NA, type = "p", col = 5 xaxs = "i", yaxs = "i") That will set the axis ranges to exactly your specified limits. This is all covered in ?par HTH, Marc Schwartz