【发布时间】:2016-07-11 14:08:20
【问题描述】:
使用此代码:
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()
我希望得到这样的图像:
但我怎么会得到这个:
请注意缺少的 x 轴和 y 轴线。 如何启用它?
这是theme_classic() 特定问题。
【问题讨论】:
-
好的,我也一样:
R version 3.3.0和ggplot2_2.1.0 -
如果您查看theme_classic 的定义,您会发现axis.line.x 和axis.line.y 都设置为element_blank。要么自己改变这个定义,要么你可以在 survminer 包中使用 theme_classic2。