p1 <- ggplot(data, aes(x=vmPFC.AF, y=GPT)) + geom_point(colour = "black",size=3.5)+ labs(x = "β", y = expression(bold(paste("GPT"))))+ geom_smooth(method = 'lm', formula = y ~ x, se = TRUE, color ='gray', size = 2, linetype = 1)+ theme_classic()+ #只有横竖坐标轴 theme(plot.margin = margin(0.3, 0.3, 0.3, 0.3, "cm"), axis.text = element_text(color = "black", size = 15, face = "bold"), axis.title = element_text(color = "black", size = 20, face = "bold"), axis.ticks = element_line(size = 2), axis.ticks.length=unit(0.3, "cm"), axis.line = element_line(size = 2, color = "black")) #coord_cartesian(xlim = c(12, 33), ylim = c(0, 1.21), expand = FALSE) p1 + annotate("text", x =0, y = 32, parse = TRUE, label = "~italic(r) ~'= - 0.4443,'~italic(p)~' = 0.00002'", size = 5, colour = "black") 通过调整r语言代码,将以上的散点图变为黑底白字
时间: 2023-11-14 12:04:59 浏览: 140
可以在原有的代码后面添加一个"theme_dark()"函数即可:
```
p1 + annotate("text", x =0, y = 32, parse = TRUE,
label = "~italic(r) ~'= - 0.4443,'~italic(p)~' = 0.00002'",
size = 5, colour = "black") +
theme_dark()
```
这样就可以将散点图变为黑底白字的样式了。
阅读全文