水平移动Y轴标题ggplot2

Move Y axis Title horizontally ggplot2

我目前有一个看起来像这样的图1,我想将 Y 轴标题水平向右移动,以便 Salary 超过 150000。下面是当前代码。

ggplot(data=SalaryGender, aes(y=Salary, x=Age, color=Gender)) + geom_point() + 
 xlab("Age") + ylab("salary") + ggtitle("Relationship Salary, Age, and Gender") + stat_smooth(method="lm", se=FALSE) + theme_bw() + theme(plot.title = element_text(face = "bold", size = 14),axis.text = element_text(face = "bold", size = 13),axis.title = element_text(face = "bold", size = 11),axis.title.y=element_text(angle=0)) 

只是想知道 annotate 是否可以做到这一点。您可能需要调整 xy 值,并在您这边添加 size

library(tidyverse)
df <- data.frame(
  Salary = c(14000, 146000, 138000, 121000, 135000, 90000, 5000, 50), 
  Age = c(20, 40, 50, 79, 40, 30, 80, 50), 
  Gender = c("Female", "Male", "Female", "Male","Female", "Male","Female", "Male")
)

ggplot(data=df, 
       aes(y=Salary, x=Age, color=Gender)) + 
  geom_point() + 
  xlab("Age") + ylab("salary") + 
  ggtitle("Relationship Salary, Age, and Gender") + 
  stat_smooth(method="lm", se=FALSE) + theme_bw() + 
  theme(plot.title = element_text(face = "bold", size = 14),
        axis.text = element_text(face = "bold", size = 13),
        axis.title = element_text(face = "bold", size = 11),
        axis.title.y = element_blank()
        ) +
  coord_cartesian(clip = "off", ylim = c(0, 150000), xlim = c(20, NA))+ 
  annotate("text", x = 12, y = 161000, label = "Salary")