?axTicks says:

    usr: numeric vector of length four, defaulting to ‘par("usr")’
          giving horizontal (‘x’) and vertical (‘y’) user coordinate
          limits.

 but this is not how the function is implemented -- in fact 'usr' should
be a vector of length two corresponding to the appropriate elements of
par("usr") [1:2 if side is 1 or 3, 3:4 if side is 2 or 4].

  A patch for src/library/graphics/man/axTicks.Rd against the latest SVN
is attached (I hope it makes it through).

  I also included an extended example of how to use axTicks without
reference to an existing plot in the logarithmic axis case: it took me
quite a bit of digging in documentation and source code to figure out
how to do this for myself, so I think it would be useful to others ...

   Ben Bolker


Index: axTicks.Rd
===================================================================
--- axTicks.Rd  (revision 54221)
+++ axTicks.Rd  (working copy)
@@ -19,19 +19,23 @@
   \item{side}{integer in 1:4, as for \code{\link{axis}}.}
   \item{axp}{numeric vector of length three, defaulting to
     \code{\link{par}("xaxp")} or \code{\link{par}("yaxp")}
-    depending on the \code{side} argument.}
-  \item{usr}{numeric vector of length four, defaulting to
-    \code{\link{par}("usr")} giving horizontal (\sQuote{x}) and vertical
-    (\sQuote{y}) user coordinate limits.}
+    depending on the \code{side} argument (\code{par("xaxp")}
+    if \code{side} is 1 or 3, \code{par("yaxp")} if side is 2 or 4).}
+  \item{usr}{numeric vector of length two giving user coordinate
+    limits, defaulting to
+    the relevant portion of \code{\link{par}("usr")} 
+    (\code{par("usr")[1:2]} or \code{par("usr")[3:4]} 
+    for \code{side} in (1,3) or (2,4) respectively).}
   \item{log}{logical indicating if log coordinates are active; defaults
-    to \code{\link{par}("xlog")} or \code{\link{par}("ylog")}.}
+    to \code{\link{par}("xlog")} or \code{\link{par}("ylog")}
+    depending on \code{side}.}
 }
 \details{
   The \code{axp}, \code{usr}, and \code{log} arguments must be consistent
   as their default values (the \code{par(..)} results) are.  If you
   specify all three (as non-NULL), the graphics environment is not used
-  at all.  Note that the meaning of \code{axp} alters very much when \code{log}
-  is \code{TRUE}, see the documentation on \code{\link{par}(xaxp=.)}.
+  at all.  Note that the meaning of \code{axp} differs significantly when 
\code{log}
+  is \code{TRUE}; see the documentation on \code{\link{par}(xaxp=.)}.
 
   \code{axTicks()} can be regarded as an \R implementation  of the
   C function \code{CreateAtVector()} in \file{..../src/main/plot.c}
@@ -64,6 +68,25 @@
     rug(T, col="red")
 }
 par(op)
+
+## an example using axTicks without reference to an existing plot
+## (copying R's internal procedures for setting axis ranges etc.):
+## standard logarithmic y axis labels
+ylims <- c(0.2,88)
+extend_lims <- function(r) { r+c(-1,1)*0.04*diff(r) }
+get_axp <- function(x) { 10^c(ceiling(x[1]),floor(x[2])) }
+## mimic par("yaxs")=="i"
+usr.i <- log10(ylims)
+axTicks(side=2,usr=usr.i,axp=c(get_axp(usr.i),n=3),log=TRUE)
+plot(0:1,ylims,log="y",yaxs="i")
+axTicks(side=2)
+## mimic (default) par("yaxs")=="r"
+usr.r <- extend_lims(log10(ylims))
+axTicks(side=2,usr=usr.r,
+        axp=c(get_axp(usr.r),3),
+        log=TRUE)
+plot(0:1,ylims,log="y",yaxs="r")
+axTicks(side=2)
 }
 \keyword{dplot}
 
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to