r - 替代 ggplot2 2.0 中已弃用的 axis.ticks.margin

标签 r plot ggplot2

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

axis.ticks.margin is deprecated. Please set margin property of axis.text instead.

我以为我可以尝试 axis.text.margin 但我收到另一个警告,说它是一个无效函数。发行说明说:

The theme setting axis.ticks.margin has been deprecated: now use the margin property of axis.ticks.

那么现在边距设置在哪里?

最佳答案

请参阅 theme 上的 ggplot 2.0 文档:

axis.text

tick labels along axes (element_text; inherits from text)

这应该位于 element_text 元素中。它的doc指向函数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")))

关于r - 替代 ggplot2 2.0 中已弃用的 axis.ticks.margin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34528664/

相关文章:

r - 查看列表中的哪个向量包含在另一个列表中的向量中(查找人员姓名匹配)

r - as_mapper(.f, ...) 错误 : argument ".f" is missing, 没有默认值,带有函数映射

matlab - 如何在matlab中制作对数图

r - 有没有办法将 geom_ribbon 与 xmin 和 xmax 的值一起使用?

r - 制作带有多个堆叠部分的黑白 ggplot 条形图的最佳方法?

r - 没有magrittr的dplyr中的博览会?

r - 如何使用 knitr 比较不同版本 R 的性能?

r - R的格式化输出

R lapply : plot data by row Error "invalid value specified for graphical parameter "pin"

r - 从多个数据的线性回归中获取 y 轴截距和斜率,并将截距和斜率值传递给数据框