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)
range of the data
units to use in the plot
number of breaks to aim for (default is 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), "hour")
#> [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), "hour")
#> [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), "hour")
#> [1] -3 0 3 6
xgx_breaks_time(c(0, 24), "hour")
#> [1] 0 3 6 9 12 15 18 21 24
xgx_breaks_time(c(0, 12), "hour")
#> [1] 0 3 6 9 12
xgx_breaks_time(c(1, 4), "day")
#> [1] 1 2 3 4
xgx_breaks_time(c(1, 12), "day")
#> [1] 0 3 6 9 12
xgx_breaks_time(c(1, 14), "day")
#> [1] 0 7 14
xgx_breaks_time(c(1, 50), "day")
#> [1] 0 7 14 21 28 35 42 49
xgx_breaks_time(c(1000, 3000), "day")
#> [1] 1080 1440 1800 2160 2520 2880
xgx_breaks_time(c(-21, 100), "day")
#> [1] -30 0 30 60 90
xgx_breaks_time(c(-1, 10), "week")
#> [1] 0 2 4 6 8 10