在ggplot2 2.0中替换弃用的axis.ticks.margin

Chu*_*xin 15 plot r ggplot2

axis.ticks.margin在ggplot2 2.0中使用时,我收到了一条警告消息:

axis.ticks.margin已弃用.请设置margin属性axis.text.

我以为我可以尝试,axis.text.margin但我得到另一个警告说这是一个无效的功能.发行说明说:

主题设置axis.ticks.margin已被弃用:现在使用axis.ticks的margin属性.

那么现在保证金设定在哪里?

sco*_*coa 20

请参阅ggplot 2.0 doc theme:

axis.text

沿轴刻度标签(element_text;从文本继承)

这应该是一个element_text元素.它的文件指向功能margin.沿着这些方向的东西应该有效:

+ theme(axis.text.x = element_text(margin=margin(5,5,10,5,"pt")),
        axis.text.y = element_text(margin=margin(5,5,10,5,"pt")))
Run Code Online (Sandbox Code Playgroud)

  • 谢谢.看来我们必须分别调整x和y的边距.对于x,只有顶部和底部工作,对于y,只有左右工作.它为我们提供了更多的精力调整它们,但与早期版本相比更复杂. (3认同)