Answers:
从ggplot2 2.0.0您可以使用margin =的参数element_text()来改变轴标题和数字之间的距离。设定的值margin上t运算,r飞行,bottom,和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。
margin =参数不起作用吗?
theme_bw。抱歉,发布整个代码不可读/混乱……
theme_bw()则theme_bw()应该前使用theme()的功能,因为在个预定义的主题有用于轴标题媒体链接参数。
根据此论坛帖子:https : //groups.google.com/forum/#!topic/ggplot2/mK9DR3dKIBU
听起来最简单的方法是在x轴之前和y轴标签之后添加换行符(\ n)。似乎比上面发布的解决方案容易(尽管很笨拙)。
ggplot(mpg, aes(cty, hwy)) +
geom_point() +
xlab("\nYour_x_Label") + ylab("Your_y_Label\n")
希望有帮助!
facet_grid,而Adam B建议的答案可以(例如,使用\ n换行)