简体   繁体   中英

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

I need some help changing the size of the titles but not the legends(y axis). I can not change them separately.

Also I need to change the graph size, more taller.

Thanks

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") 

在此处输入图像描述

The theme ggplot function has a lot of different pointers to different features of your plot you want to change. Adapting the code you provided plot.title will ONLY increase the font size of your plots title. There are other specifications for axis titles and legend titles that will only change those fonts as well (see axis.text and legend.text as well as there variations).

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") 

You can change the size of the plot when you save it by specifying the width and height and changing the units:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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