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
xgx_breaks_time(data_range, units_plot, number_breaks = 5)
numeric vector of breaks
for the extended breaks function, weights is a set of 4 weights for
simplicity - how early in the Q order are you
coverage - labelings that don't extend outside the data: range(data) / range(labels)
density (previously granularity) - how close to the number of ticks do you get (default is 5)
legibility - has to do with fontsize and formatting to prevent label overlap
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.
xgx_breaks_time(c(0, 5), "h")
#> [1] 0.0 0.6 1.2 1.8 2.4 3.0 3.6 4.2 4.8
xgx_breaks_time(c(0, 6), "h")
#> [1] 0.0 0.6 1.2 1.8 2.4 3.0 3.6 4.2 4.8 5.4 6.0
xgx_breaks_time(c(-3, 5), "h")
#> [1] -3 0 3 6
xgx_breaks_time(c(0, 24), "h")
#> [1] 0 3 6 9 12 15 18 21 24
xgx_breaks_time(c(0, 12), "h")
#> [1] 0 3 6 9 12
xgx_breaks_time(c(1, 4), "d")
#> [1] 1 2 3 4
xgx_breaks_time(c(1, 12), "d")
#> [1] 0 3 6 9 12
xgx_breaks_time(c(1, 14), "d")
#> [1] 0 7 14
xgx_breaks_time(c(1, 50), "d")
#> [1] 0 7 14 21 28 35 42 49
xgx_breaks_time(c(1000, 3000), "d")
#> [1] 700 1400 2100 2800
xgx_breaks_time(c(-21, 100), "d")
#> [1] -14 0 14 28 42 56 70 84 98
xgx_breaks_time(c(-1, 10), "w")
#> [1] 0 2 4 6 8 10