Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

xgx_breaks_time

Sets the default breaks for a time axis


Description

xgx_breaks_time sets the default breaks for a time axis, given the units of the data and the units of the plot. It is inspired by scales::extended_breaks

Usage

xgx_breaks_time(data_range, units_plot, number_breaks = 5)

Arguments

data_range

range of the data

units_plot

units to use in the plot

number_breaks

number of breaks to aim for (default is 5)

Details

for the extended breaks function, weights is a set of 4 weights for

  1. simplicity - how early in the Q order are you

  2. coverage - labelings that don't extend outside the data: range(data) / range(labels)

  3. density (previously granularity) - how close to the number of ticks do you get (default is 5)

  4. legibility - has to do with fontsize and formatting to prevent label overlap

Value

numeric vector of breaks

References

Talbot, Justin, Sharon Lin, and Pat Hanrahan. "An extension of Wilkinson’s algorithm for positioning tick labels on axes." IEEE Transactions on visualization and computer graphics 16.6 (2010): 1036-1043.

Examples

xgx_breaks_time(c(0, 5), "h")
xgx_breaks_time(c(0, 6), "h")
xgx_breaks_time(c(-3, 5), "h")
xgx_breaks_time(c(0, 24), "h")
xgx_breaks_time(c(0, 12), "h")
xgx_breaks_time(c(1, 4), "d")
xgx_breaks_time(c(1, 12), "d")
xgx_breaks_time(c(1, 14), "d")
xgx_breaks_time(c(1, 50), "d")
xgx_breaks_time(c(1000, 3000), "d")
xgx_breaks_time(c(-21, 100), "d")
xgx_breaks_time(c(-1, 10), "w")

xgxr

Exploratory Graphics for Pharmacometrics

v1.1.1
MIT + file LICENSE
Authors
Andrew Stein [aut, cre], Alison Margolskee [aut], Fariba Khanshan [aut], Konstantin Krismer [aut] (<https://orcid.org/0000-0001-8994-3416>), Matthew Fidler [ctb] (<https://orcid.org/0000-0001-8538-6691>), Novartis Pharma AG [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.