[R] graphical parameters in plot
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri Jun 2 21:52:42 CEST 2000
Angelo Canty <canty at discrete.Concordia.CA> writes:
> I'm using plot to make a simple plot but I want to control where
> the tick marks go on bot axes. The graphical parameters xaxp and
> yaxp seem to be ignored by the plot function so I tried setting them
> using
> op <- par(no.readonly=T)
> par(xaxp=c(-2.4,-2.2,5), yaxp=c(-2500,10000,6))
> plot(...)
> par(op)
> but they are still ignored.
>
> Next I tried to use the axis function as follows
> op <- par(no.readonly=T)
> par(xaxt="n", yaxt="n")
> plot(...)
> axis(1,seq(-2.4,-2.2,length=5))
> axis(2,seq(-2500,10000,length=6), cex.axis=0.9)
> par(op)
> but no axis labels are plotted.
>
> Moving par(op) before the calls to axis causes the first call to axis to
> extend the x-axis to the edge of the screen and the second call results
> in a 0 being placed at the bottom of the y-axis.
>
> Is this a bug or is it just that it's Friday afternoon? In any case
> can someone please help me out here.
>
> I'm using the following verison of R
> platform sparc-sun-solaris2.6
> arch sparc
> os solaris2.6
> system sparc, solaris2.6
> status
> major 1
> minor 0.0
Some bugs relating to axes were fixed in 1.0.1, but your first example
still won't work. This looks suspiciously like a bug - to force axis
to actually use xaxp/yaxp one has to pass at=NULL explicitly and it
doesn't work to pass them to plot or set them beforehand with par
because they're being recalculated along the way. (I don't think the
latter is a bug -- to use "current settings" would imply inheriting
axes from the previous plot which you likely do not want! However,
passing them explicitly to plot ought to work.)
Your 2nd example is flawed: Once you set par(xaxt="n"), axis(1,...)
will plot nothing, whatever arguments you give it.
What does work is stuff like
plot(1,xaxt="n")
axis(1,at=seq(from=0.7,to=1.3,length=5))
although I suspect that the bug in 1.0.0 prevents this from working,
and you have to work around it with
par(xaxt="n");plot(1);par(xaxt="s")
axis(1,at=seq(from=0.7,to=1.3,length=5))
The version that I normally use (because I can't remember all those
par() settings...) goes along the lines of
plot(1, axes=F)
axis(1,at=seq(from=0.7,to=1.3,length=5))
axis(2)
box()
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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