[R] Graph with values of coordinates of points in x axis

Romain Francois francoisromain at free.fr
Wed Jun 15 10:49:56 CEST 2005


Le 15.06.2005 10:35, Massimiliano Tripoli a écrit :

>Hi all,
>
>I want to draw a line with the values of x marked in X axis.
>
>I tried with
>x <- c(0,6,12,18,24,30)  #coordinates of points x
>y <- c(2,5,7,5,7,16)     #coordinates of points y
>plot(x,type="n",xlab="Months",ylab="Y 
>values",main="main",ylim=c(0,16),xlim=c(0,30))
>lines(x,y)
>
>The graph shows by default an increment of the sequence in x axis that I'm 
>not able to change.
>I'would like to have 0,6,12,18,24,30 and not 0,10,15,20,25,30.
>Any hint is appreciated.
>  
>
Hello, you can do what you want by doing a call to axis, thus in the 
plot call you have to use : axes=F

x <- c(0,6,12,18,24,30)  #coordinates of points x
y <- c(2,5,7,5,7,16)     #coordinates of points y
plot(x,type="n",xlab="Months",ylab="Y 
values",main="main",ylim=c(0,16),xlim=c(0,30),axes=F)
axis(2)
axis(1,(0:5)*6)
lines(x,y)
box()


Romain

-- 
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
~~~~~~      Romain FRANCOIS - http://addictedtor.free.fr         ~~~~~~
~~~~        Etudiant  ISUP - CS3 - Industrie et Services           ~~~~
~~                http://www.isup.cicrp.jussieu.fr/                  ~~
~~~~           Stagiaire INRIA Futurs - Equipe SELECT              ~~~~
~~~~~~   http://www.inria.fr/recherche/equipes/select.fr.html    ~~~~~~
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~




More information about the R-help mailing list