How to change the default font size in ggplot2

白昼怎懂夜的黑 提交于 2019-12-03 17:53:50

问题


I'd like to know if it is possible to change some default parameters of ggplot2 graphics, like font size for instance, for a whole R session. The idea is to avoid setting them for each plot.


回答1:


Use theme_set()

theme_set(theme_gray(base_size = 18))
qplot(1:10, 1:10)




回答2:


Use theme_set if you want to update for the remainder of your active session:

theme_set(theme_grey(base_size = 18)) 

If you only want to change one graph you can set the base_size in the theme:

qplot(1:10, 1:10) + theme_grey(base_size = 18) 
ggplot(mtcars, aes(x = mpg, y = cyl)) + 
geom_point() +
theme_grey(base_size = 18) 


来源:https://stackoverflow.com/questions/11955229/how-to-change-the-default-font-size-in-ggplot2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!