0

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

enter image description here

teunbrand
  • 33,645
  • 4
  • 37
  • 63
  • 1
    ggplot2 themes contains various types of titles, and can often be changed independently. Which titles would you like to have larger? Also, changing the size of the graph depends on how you are exporting or viewing them. At what size and with which device do you want to export your graph? Lastly, can you change your code such that it produces a graph that we could debug when we copy-paste the code in our R sessions? This also means including some (dummy) data or using a standard dataset (see https://stackoverflow.com/a/5963610/11374827 for more tips). – teunbrand Apr 15 '21 at 19:39
  • Thank you very much, I want to change the legend in the circle – JhonnyQuestions Apr 15 '21 at 20:32
  • I exported the graph with ggsave, everything ok :) – JhonnyQuestions Apr 15 '21 at 20:33

1 Answers1

0

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")
Jeffrey Brabec
  • 481
  • 6
  • 11