[英]How to enable x-axis and y-axis line in GGPLOT theme_classic()
With this code: 使用此代码:
library(ggplot2)
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
p <- ggplot(ToothGrowth, aes(x=dose, y=len, color=dose, shape=dose)) +
geom_jitter(position=position_jitter(0.2))+
labs(title="Plot of length by dose",x="Dose (mg)", y = "Length")
p + theme_classic()
I expect to get image like this: 我希望得到这样的图像:
But how come I get this instead: 但是我怎么得到这个呢?
Notice the missing x-axis an y-axis line. 注意缺少的x轴和y轴线。 How can I enable it?
如何启用它?
This is theme_classic()
specific issue. 这是
theme_classic()
特定问题。
Here is a solution from this GitHub issue 这是此GitHub 问题的解决方案
p + theme_classic() +
theme(axis.line.x = element_line(colour = 'black', size=0.5, linetype='solid'),
axis.line.y = element_line(colour = 'black', size=0.5, linetype='solid'))
Edit 编辑
If you are running into this issue, updating ggplot2
should fix the issue, and the solution above shouldn't be necessary. 如果您遇到此问题,则更新
ggplot2
应该可以解决该问题,并且上面的解决方案不是必需的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.