Compute about n
'round' values that are about equally spaced
in a transformed (plotting) scale and cover the range of the values
in x
.
prettyscale(x, transformed = FALSE, plscale = "log10", inverse = NULL,
range = NULL, range.transformed = NULL, n = NULL, logscale = NULL)
Numeric vector of tick mark locations in transformed scale,
with an attribute ticklabels
containing the appropriate
tick marks and labels (in original scale)
numeric vector of data (original scale)
logical: Is x
scaled according to
plscale
rather than in original scale?
name of the transformation defining the plotting scale
back (or inverse) back transformation
admissible range of original and transformed values, respectively. Usually not needed, cf. Details
approximate number of tickmark locations.
If of length >=2
, n[2]
can be varied to obtain more
adequate locations. See Details.
if NULL
, R's function axTicks
will be called if the plscale is a log function.
W. A. Stahel
prettyscale
generates n+2
"anchor" values in the
transformed scale which cover the range of the transformed x
values and are equidistant within the range.
It then back-transforms these anchor values. For each one of them,
say c
,
it seeks a pretty value near to it by the following construction:
it calls the R function pretty
on the range given by the
back-transformed neighboring anchor values, asking for n[2]
pretty values. From these, it chooses the one for which the
transformed value is closest to the transformed c
.
Therefore, if n[2]
is large, the pretty values may be less
pretty, whereas small n[2]
may lead to equal pretty values
for neighboring anchors and thus to too few resulting pretty values.
The default value for n[2]
is 3.
The ranges are needed to get the limits as pretty values when
appropriate (and to avoid warning messages).
They are generated in the function for the commonly used plscales
and may be given as attributes of the plscale
function,
see Examples.
axTicks, plticks
prettyscale(10^rnorm(10))
prettyscale(c(0.5, 2, 10, 90), plscale="sqrt")
prettyscale(c(50,90,95,99), plscale="asinp", n=10)
## asinp has the useful attributes:
asinp
Run the code above in your browser using DataLab