prettyscale: Pretty Tickmark Locations for Transformed Scales

prettyscaleR Documentation

Pretty Tickmark Locations for Transformed Scales

Description

Compute about n 'round' values that are about equally spaced in a transformed (plotting) scale and cover the range of the values in x.

Usage

prettyscale(x, transformed = FALSE, plscale = "log10", inverse = NULL, 
    range = NULL, range.transformed = NULL, n = NULL, logscale = NULL)

Arguments

x

numeric vector of data (original scale)

transformed

logical: Is x scaled according to plscale rather than in original scale?

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 >=2, n[2] can be varied to obtain more adequate locations. See Details.

logscale

if NULL, R's function axTicks will be called if the plscale is a log function.

Details

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.

Value

Numeric vector of tick mark locations in transformed scale, with an attribute ticklabels containing the appropriate tick marks and labels (in original scale)

Note

The function does not always lead to consistent results. Increasing n sometimes leads to fewer resulting values.

Author(s)

W. A. Stahel

See Also

axTicks, plticks

Examples

  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

plgraphics documentation built on Oct. 19, 2023, 3 p.m.