繁体   English   中英

如何在 r 中使用 ggplot 更改图例大小而不是标题?

[英]How to change legend size but not titles with ggplot in r?

我需要一些帮助来更改标题的大小,而不是图例(y 轴)。 我不能单独更改它们。

我还需要更改图形大小,更高。

谢谢

grafico <- ggplot(meanIMcomunas, aes(x= IM, y= Comuna)) 
          + geom_point(aes(color = IM),size =2) 
          + labs(title = "Promedio de IM por comuna")
          + theme(text =element_text(size = 2))+scale_color_viridis(option = "D") 

在此处输入图像描述

ggplot function theme有很多不同的指针,指向您想要更改的 plot 的不同功能。 调整您提供的代码 plot.title 只会增加绘图标题的字体大小。 轴标题和图例标题还有其他规范,它们也只会更改那些 fonts(请参阅axis.textlegend.text以及其他变体)。

grafico <- ggplot(meanIMcomunas, aes(x= IM, y= Comuna)) 
          + geom_point(aes(color = IM),size =2) 
          + labs(title = "Promedio de IM por comuna")
          + theme(plot.title = element_text(size = 20))+ 
scale_color_viridis(option = "D") 

保存时可以通过指定宽度和高度并更改单位来更改 plot 的大小:

ggsave(grafico, file = "my_file.png", width = 10, height = 10, units = "in")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM