我想在辅助轴上添加一个不同的变量,但似乎仅使用参数sec仅取主轴的某些转换值即可。轴= sec_axis(trans =〜。(+ /-/ *等)) 。运行代码直到coord_flip()。在该图表中,我希望在主要轴上显示mpg,在次要轴上显示disp。我该怎么办?
library(tidyverse)
mtcars %>%
rownames_to_column() %>%
slice(1:5) %>%
ggplot(aes(x=rowname)) +
geom_col(aes(y = mpg, fill = factor(carb)), position = "stack") +
geom_point(aes(y = disp), color = "Orange", size = 5) +
coord_flip() +
scale_y_continuous(sec.axis = sec_axis(~ disp_doesn't_word_here))
答案 0 :(得分:1)