我刚刚将ggplot2更新为2.0.0,并且在更换一些已弃用的代码时遇到了问题。当我制作图表时,我倾向于设置指向内部的刻度线,所以我会这样做:
p <- ggplot(mtcars, aes(x = cyl, y = mpg)) +
geom_point()
p + theme_bw() +
theme(text = element_text(size = 21)) +
theme(axis.ticks.length = unit(-0.25, "cm"), axis.ticks.margin = unit(0.5, "cm"))
这不再有效,因为:
Warning message:
`axis.ticks.margin` is deprecated. Please set `margin` property of `axis.text` instead
没有边距,刻度标签与面板边框重叠。我原以为我现在应该用这样的东西替换最后一行:
theme(axis.ticks.length = unit(-0.25, "cm")) +
theme(axis.text = element_text(margin = margin(0.5, 0.5, 0.5, 0.5, unit = "cm")))
但这似乎没有做任何事情,而我现在有点卡住了。非常感谢帮助!