使用此代码:
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()
Run Code Online (Sandbox Code Playgroud)
我希望得到这样的图像:
但是我怎么会得到这个:
注意缺少的 x 轴和 y 轴。我怎样才能启用它?
这是theme_classic()具体问题。
这是此 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'))
Run Code Online (Sandbox Code Playgroud)
编辑
如果您遇到此问题,更新ggplot2应该可以解决问题,并且不需要上述解决方案。