wilkinson {labeling}R Documentation

Wilkinson's labeling algorithm

Description

Wilkinson's labeling algorithm

Usage

  wilkinson(dmin, dmax, m,
    Q = c(1, 5, 2, 2.5, 3, 4, 1.5, 7, 6, 8, 9),
    mincoverage = 0.8,
    mrange = max(floor(m/2), 2):ceiling(6 * m))

Arguments

dmin

minimum of the data range

dmax

maximum of the data range

m

number of axis labels

Q

set of nice numbers

mincoverage

minimum ratio between the the data range and the labeling range, controlling the whitespace around the labeling (default = 0.8)

mrange

range of m, the number of tick marks, that should be considered in the optimization search

Value

vector of axis label locations

Note

Ported from Wilkinson's Java implementation with some changes. Changes: 1) m (the target number of ticks) is hard coded in Wilkinson's implementation as 5. Here we allow it to vary as a parameter. Since m is fixed, Wilkinson only searches over a fixed range 4-13 of possible resulting ticks. We broadened the search range to max(floor(m/2),2) to ceiling(6*m), which is a larger range than Wilkinson considers for 5 and allows us to vary m, including using non-integer values of m. 2) Wilkinson's implementation assumes that the scores are non-negative. But, his revised granularity function can be extremely negative. We tweaked the code to allow negative scores. We found that this produced better labelings. 3) We added 10 to Q. This seemed to be necessary to get steps of size 1. It is possible for this algorithm to find no solution. In Wilkinson's implementation, instead of failing, he returns the non-nice labels spaced evenly from min to max. We want to detect this case, so we return NULL. If this happens, the search range, mrange, needs to be increased.

Author(s)

Justin Talbot justintalbot@gmail.com

References

Wilkinson, L. (2005) The Grammar of Graphics, Springer-Verlag New York, Inc.


[Package labeling version 0.4.3 Index]