如何添加小标题并更改R中ggplot图的字体大小? [英] How can I add a subtitle and change the font size of ggplot plots in R?

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

问题描述

我尝试使用 + opts(subtitle =text)添加一个字幕,但没有出现。主标题确实有效( + opts(title =text))。 我还想使用较大的字体作为坐标轴(标签和坐标),但我不知道该怎么做。 解决方案

code> theme_get()会向您显示您可以在 opts()中使用的隐藏选项,后0.91是 theme()



当前:

 主题(axis.text.x = element_text(size = X))
主题(axis.text.y = element_text(size = X))

Pre 0.91:

<$ p
$ opts(axis.text.y = theme_text(size = X))
opts c $ c>

将尺寸更改为您所需的尺寸。



关于标题,您可以使用\ n将其余文本移动到新行:

  labs(title =text \ more text)

Pre 0.91:

  opts(title =text \ more text)



ggplot2没有字幕功能。但是,您可以使用任何标签中的\ term来下拉一行。

I tried adding a subtitle using +opts(subtitle="text") but nothing showed up. The main title does work (+opts(title="text")).

I would also like to use a larger font for the axis (labels and coordinates), but I can't tell how to do that.

解决方案

theme_get() will show you the "hidden" options that you can use in opts(), post 0.91 it's theme()

Current:

theme(axis.text.x=element_text(size=X))
theme(axis.text.y=element_text(size=X))

Pre 0.91:

opts(axis.text.x=theme_text(size=X))
opts(axis.text.y=theme_text(size=X))

Change size, to your desired size.

wrt the title, you can use "\n" to move the remaining text to a new line:

Current:

labs(title="text \n more text")

Pre 0.91:

opts(title="text \n more text") 

ggplot2 doesn't have "subtitle" functionality. But you can use the \n term in any of the labels to drop down a line.

这篇关于如何添加小标题并更改R中ggplot图的字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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