如何在ggplot中将虚线和虚线末尾的水平条添加到我的boxplot中?默认情况下,它会创建一条从盒子出来的垂直线。请看下面的例子,我想怎么做:
以下是我的代码
p <- ggplot(data, aes(factor(Length,levels=18:26), logFC)) +
geom_boxplot(fill = "white") +
coord_cartesian(ylim=c(-5,5)) +
theme_bw(base_size=45) +
scale_x_discrete("", breaks=factor(18:26), drop=FALSE)

发布于 2015-03-31 23:06:16
@CMichael引用了答案。这仅仅说明了这一点。首先,是一些玩具数据。
year <- rep("2014", 10)
total <- c(seq(55, 90, 5), 100, 40)
df <- data.frame(year = as.factor(year), total = total)然后是曲线图,显示虚线和颜色。
ggplot(df, aes(x=factor(year), y=total)) +
geom_boxplot(linetype = "dotted", color = "red") +
theme_bw()

https://stackoverflow.com/questions/26232835
复制相似问题