有时我的 y 轴标签很长,这会导致标题开始位置太靠右。如何在 y 轴标签上方开始我的 ggplot 标题,而不是从 y 轴标签右侧开始?
library(tidyverse)
mtcars |>
rownames_to_column('model') |>
ggplot(aes(x=model, y = mpg)) +
geom_col() +
coord_flip() +
labs(title = 'How can I start this title in the upper left corner above the model labels?')
像这样添加这个函数
scale_y_discrete(position='right')
library(tidyverse)
mtcars |>
rownames_to_column('model') |>
ggplot(aes(x=model, y = mpg)) +
geom_col() +
coord_flip() +
labs(title = 'How can I start this title in the upper left corner above the model labels?')+
scale_y_discrete(position = "right")