Set Y-Axis Formatting for Chart Plots
set_axis.RdDynamically determines the appropriate Y-axis breaks, labels, and title based on the maximum value in a vector of numeric data. Used to standardize axis formatting across plots.
Value
A list with components:
breaks— Either a numeric vector orwaiver().labels— A labeling function or character vector.title— A character string for axis title.
Examples
set_axis(c(100, 500, 1000), units = "Persons")
#> $breaks
#> list()
#> attr(,"class")
#> [1] "waiver"
#>
#> $labels
#> list()
#> attr(,"class")
#> [1] "waiver"
#>
#> $title
#> [1] "Persons"
#>
set_axis(c(5e8, 1.5e9), units = "USD")
#> $breaks
#> [1] 0.0e+00 5.0e+08 1.0e+09 1.5e+09
#>
#> $labels
#> [1] "0" "0.5" "1.0" "1.5"
#>
#> $title
#> [1] "Billions USD"
#>