在ggplot2中更改轴标题和标签的大小 [英] Change size of axes title and labels in ggplot2

查看:4720
本文介绍了在ggplot2中更改轴标题和标签的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的问题,我正在努力寻找答案。我希望这里有人能够帮助我。

I have a really simple question, which I am struggling to find the answer to. I hoped someone here might be able to help me.

以下是一个示例数据框:

An example dataframe is presented below:

a <- c(1:10)
b <- c(10:1)
df <- data.frame(a,b)
library(ggplot2)
g = ggplot(data=df) + geom_point(aes(x=a, y=b)) +
  xlab("x axis")
g

我只想了解如何更改轴标题和轴标签的文字大小。

I just want to learn how I change the text size of the axes titles and the axes labels.

推荐答案

您可以使用参数 axis.text = 和<$ c来更改轴文本和标签大小$ c> axis.title = 在函数 theme()中。例如,如果您需要更改x轴标题大小,请使用 axis.title.x =

You can change axis text and label size with arguments axis.text= and axis.title= in function theme(). If you need, for example, change only x axis title size, then use axis.title.x=.

g+theme(axis.text=element_text(size=12),
        axis.title=element_text(size=14,face="bold"))

有很多关于设置不同的 theme()参数的例子在 ggplot2页面

There is good examples about setting of different theme() parameters in ggplot2 page.

这篇关于在ggplot2中更改轴标题和标签的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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