ggplot2
ggplot2 copied to clipboard
Discrete labels from break names
This PR aims to fix #6147 and fix #6089.
Briefly, names(breaks) is used as default label for discrete breaks.
We also use this mechanism to populate discrete secondary labels (#6089).
Reprex from #6147 with a secondary axis:
devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
ggplot(mpg, aes(drv, hwy)) +
geom_boxplot() +
scale_y_continuous(
breaks = c(twenty = 20, thirty = 30, fourty = 40)
) +
scale_x_discrete(
breaks = c("four-wheel" = 4, forward = "f", reverse = "r"),
sec.axis = dup_axis()
)

Created on 2024-10-18 with reprex v2.1.1