When I add a secondary axis to a plot, something weird happens with the transformation formula. I'm very confused, so I created a very simple reprex. I expect the ~ -.
formula to just show negative numbers, but this doesn't work. Please help :)
library(tibble)
library(ggplot2)
dat <- tibble(x = 1:10, y = 11:20)
pl <- ggplot(dat, aes(x = x, y = y)) +
geom_point()
# add a secondary "negative" axis as an example
pl +
scale_y_continuous("positive", sec.axis = sec_axis(~ -., "negative!"))
# do the same on a reversed axis
pl +
scale_y_reverse("positive", sec.axis = sec_axis(~ -., "negative!"))
# my actual formula that isn't showing up correctly
pl +
scale_y_reverse(sec.axis = sec_axis(
~ sqrt((0.0449 * 1e6) / (. - 0.167)) - 273.15,
"Temperature (°C)"))