【发布时间】:2012-02-03 16:24:47
【问题描述】:
我目前正在使用来自 github 的最新版本的 ggplot2。
在 0.8.9 版本中,我可以执行以下操作来增加 axis.title 和 axis.text 之间的空间:
之前:
ggplot(diamonds, aes(clarity)) + geom_bar() + opts(
axis.title.x = theme_text(vjust=-1.1)
)
修复:
ggplot(diamonds, aes(clarity)) + geom_bar() + opts(
axis.title.x = theme_text(vjust=-1.1),
plot.margin = unit(c(1, 1, 0.8, 0.5), "lines")
)
并且axis.title变得完全可见。
在最新的github版本ggplot2中plot.margin对axis.title没有影响:
ggplot(diamonds, aes(clarity)) + geom_bar() + opts(
axis.title.x = theme_text(vjust=-0.2),
plot.margin = unit(c(1, 1, 2, 0.5), "lines"))
(注意底部边距增加 - 我无法让 plot.background 在最新的开发版本中工作)
似乎0.8.9允许axis.title移动到plot.margin创建的额外空间上,但在最新的开发版本中是不允许的。
在最新的开发版本中是否有完成此任务的新方法(或快速修复它)?
任何帮助表示赞赏。
【问题讨论】:
-
@BrianDiggs 非常感谢添加图片,但是如果我编辑我的帖子以添加其他信息,除非我恢复使用链接,否则我不能保存它。
-
我把数据放回去了。如果您在合理的时间内没有在这里得到回复,请尝试 ggplot2 或 ggplot2-dev 列表,它们都托管在 google 群组中。
-
如果您可以将此作为错误提交,或者在 ggplot2-dev 邮件列表中提及它会很有用。
-
@hadley 我添加了一个快速修复的错误报告,但链接到此处了解详细信息 - 希望没关系。
-
这在上个版本中已经改变了,你应该使用下面的代替
theme(axis.title.y=element_text(margin=margin(20,0,0,0))),去here