如何在 ggplot2 R 中更改 stat_poly_eq 上的字体大小

How to change font size on stat_poly_eq in ggplot2 R

我在 p 中存储了一个 ggplot,并希望添加一个 poly_stat_eq 层来显示曲线方程。我想更改文本的字体大小,但找不到有关如何实现它的文档

p + 
  stat_poly_eq(formula = y ~ x, 
               aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")),
               label.x = 4, label.y = -5, parse = TRUE) 

你可以直接设置size = some real number。在你的情况下,这看起来像

 p + 
  stat_poly_eq(formula = y ~ x, 
               aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")),
               label.x = 4, label.y = -5, parse = TRUE, size = 2.4) 

只要把size =后面的数字改成你想要的就行了。 ggpmisc 附加示例页面也是查看的好地方。你可以找到 here。希望对您有所帮助。