Closed
Description
I've been testing out the new discrete secondary axis functionality in the DEV version.
Firstly, awesome work and a great advance!
I felt the discrete secondary axis labels and breaks arguments were working in unexpected ways in that:
- default sec.axis discrete labels are numeric - should they be the actual labels instead?
- palette moves the breaks in scale_*_discrete, but breaks does this in sec.axis - should the sec.axis operate in the same way as the discrete scale?
I'm not familiar with the internals. So there be valid reasons for this that I'm unaware of. Anyway, great work on this. It'll be a super useful feature. Sorry to bombard with issues. As always, feel free to close, if it is working the way you want it to
library(tidyverse)
data <- data.frame(x = c("A", "B", "C"), y = c("D", "E", "F"))
#sec.axis discrete labels are numeric
ggplot(data, aes(x, y)) +
geom_point() +
scale_x_discrete(
sec.axis = dup_axis()
) +
labs(title = "default sec.axis discrete labels are numeric")
#palette moves the breaks in scale_*_discrete but breaks does this in sec.axis
ggplot(data, aes(x, y)) +
geom_point() +
scale_x_discrete(
palette = \(x) c(0.5, 1.5, 3.5),
sec.axis = dup_axis(
breaks = c(1.3, 3, 4)
)
) +
labs(title = "palette moves the breaks in scale_*_discrete but breaks does in sec.axis")
Created on 2024-09-07 with reprex v2.1.1