y轴标题出现得太靠近轴文本。
ggplot(mpg, aes(cty, hwy)) + geom_point()
我试图改变许多参数与价值theme()
但似乎没有任何帮助。
y轴标题出现得太靠近轴文本。
ggplot(mpg, aes(cty, hwy)) + geom_point()
我试图改变许多参数与价值theme()
但似乎没有任何帮助。
从ggplot2 2.0.0
可以使用margin =
的参数element_text()
来改变轴标题和数字之间的距离。 设置的值margin
上t
运算, r
飞行, b
ottom,和l
元件的EFT侧。
ggplot(mpg, aes(cty, hwy)) + geom_point()+
theme(axis.title.y = element_text(margin = margin(t = 0, r = 20, b = 0, l = 0)))
margin
,也可用于其他element_text
元素(参见?theme
),如axis.text.x
, axis.text.y
和title
。
基于此论坛的帖子: https://groups.google.com/forum/#!topic/ggplot2/mK9DR3dKIBU
听起来好像是最容易的事情就是你的x轴前加一个换行符(\ n)和你的Y轴的标签后。 似乎轻松了很多(虽然笨)比上面张贴的解决方案。
ggplot(mpg, aes(cty, hwy)) +
geom_point() +
xlab("\nYour_x_Label") + ylab("Your_y_Label\n")
希望帮助!