【发布时间】:2016-03-12 16:28:33
【问题描述】:
我无法用 ggplot2 重现一个简单的图表。我的目标是显示 x 和 y 轴。这个取自网站的基本示例不起作用,我不明白为什么。任何见解都非常感谢!
library(ggplot2)
df <- data.frame(x = 1:3, y = 1:3)
ggplot(df, aes(x, y)) + geom_point()+ theme_classic() + ggtitle("theme_classic()")
我也尝试过使用
theme(axis.line = element_line(colour = "grey50"))
【问题讨论】:
-
你是从cowplot那里得到的吗?
theme_classic为您提供文档所拥有的内容 docs.ggplot2.org/current/ggtheme.htmlggplot(diamonds, aes(clarity, fill = cut)) + geom_bar() + cowplot::theme_cowplot() -
这在 ggplot 2.0.0 中有效,但在 ggplot 2.1.0 中不再有效。不过,您仍然可以通过添加
+ theme(axis.line.x = element_line(color = "black"), axis.line.y = element_line(color = "black"))来治愈它。也许他们改变了theme-defaults.r -
一个错误:见here 和这个bug report。