增加y轴上文本和标题之间的距离 [英] Increase distance between text and title on the y-axis

查看:169
本文介绍了增加y轴上文本和标题之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



  ggplot(mpg,aes(cty,hwy) )+ geom_point()



我试着用 theme()

解决方案

ggplot2 2.0.0 c>您可以使用 element_text() margin = 参数来更改轴标题和数字之间的距离。在 t op上设置保证金的值, r ight, b ottom,并且 l 元素的右边。

  ggplot(mpg,aes(cty,hwy))+ geom_point()+ 
主题(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


The y-axis title appears too close to the axis text.

ggplot(mpg, aes(cty, hwy)) + geom_point()

I have tried changing the value of many parameters with theme() but none seems to help.

解决方案

From ggplot2 2.0.0 you can use the margin = argument of element_text() to change the distance between the axis title and the numbers. Set the values of the margin on top, right, bottom, and left side of the element.

ggplot(mpg, aes(cty, hwy)) + geom_point()+
  theme(axis.title.y = element_text(margin = margin(t = 0, r = 20, b = 0, l = 0)))


margin can also be used for other element_text elements (see ?theme), such as axis.text.x, axis.text.y and title.

这篇关于增加y轴上文本和标题之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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