[R] xaxp and grid()

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Jun 26 08:30:13 CEST 2002



Daniel Mastropietro wrote:
> 
> Hello,
> 
> I use the option xaxp in the plot function and it is not recognized.
> This affects the result of the function grid(), since it takes the default
> tick marks used by the plot function, which is not what I want.
> 
> See for example the result of:
> 
> plot(1:10,1:10,xaxp=c(1,10,9))
> grid(9);

plot sets par("xaxp") itself. You can change it before calling grid()
(and after plot() has set it) as follows:

 plot(1:10)
 par(xaxp = c(1, 10, 9))
 grid(9)

If you want to have tickmarks analogously, you have to create the axis
manually:

 plot(1:10, xaxt = "n")
 axis(1, 1:10)
 par(xaxp = c(1, 10, 9))
 grid(9)

Or just create the grid with abline():

 plot(1:10, xaxt = "n")
 axis(1, 1:10)
 abline(v = 1:10, h = seq(2, 10, 2), col = "grey")

 
> With grid(9) I want to set a vertical line at each integer value, but this
> divides the interval [2,10] in 9 intervals, just because the first and last
> tick in the x axis are 2 and 10, not 1 and 10 as I request with the xaxp
> option.
> 
> Anybody knows how to go around this problem?
> 
> I am using R1.5.0 under Windows Me.

Uwe Liges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list