更改ggplot图表的字体大小 [英] Change the font size of a ggplot chart

查看:229
本文介绍了更改ggplot图表的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ggplot图表中,我有一个图表标题以及x和y轴的值.当我将图表另存为图像时,标签很小.

In a ggplot chart I have a title for chart and values for x and y axis. When I save the chart as an image the labels are tiny.

我尝试使用以下方式更改字体大小:

I tried to change the font size using:

size = 21

但是没有用.有什么简单的方法可以改变整个图表的字体大小?

But it didn't work. Is there any easy way to chage the font size for the whole chart?

推荐答案

使用函数 theme()更改文本大小,然后选择需要修改的元素.要为绘图中的所有文本设置字体大小,应更改 text 属性.

Size of texts are changed using function theme() and then choosing element you need to modify. To set font size for all texts in plots attribute text should be changed.

ggplot(mtcars,aes(cyl,mpg))+geom_point()+theme(text=element_text(size=21))

这篇关于更改ggplot图表的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆