当我在绘图中添加辅助轴时,转换公式会发生一些奇怪的事情。我很困惑,所以我创建了一个非常简单的reprex。我希望~ -.公式只显示负数,但这不起作用。请帮忙 :)
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)"))