prettyscale | R Documentation |
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)
x |
numeric vector of data (original scale) |
transformed |
logical: Is |
plscale |
name of the transformation defining the plotting scale |
inverse |
back (or inverse) back transformation |
range, range.transformed |
admissible range of original and transformed values, respectively. Usually not needed, cf. Details |
n |
approximate number of tickmark locations.
If of length |
logscale |
if |
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.
Numeric vector of tick mark locations in transformed scale,
with an attribute ticklabels
containing the appropriate
tick marks and labels (in original scale)
The function does not always lead to consistent results.
Increasing n
sometimes leads to fewer resulting values.
W. A. Stahel
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.