R 如何在geom_长方体绘图上自定义与长方体本身不同的胡须线

R 如何在geom_长方体绘图上自定义与长方体本身不同的胡须线,r,ggplot2,boxplot,R,Ggplot2,Boxplot,由于终端用户要求严格,我需要了解geom_框plot上的胡须线是否可以与框本身不同的颜色或类型 经过刚才的考虑,我创建了一个最小的示例 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_boxpl

由于终端用户要求严格,我需要了解
geom_框
plot上的胡须线是否可以与框本身不同的颜色或类型

经过刚才的考虑,我创建了一个最小的示例

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()

评论后编辑:我没有发现用户20650优雅地指出的问题。这是它的答案——两次绘制箱线图

ggplot(df, aes(x=factor(year), y=total)) + 
  geom_boxplot(linetype = "dotted", color = "red") +
  geom_boxplot(aes(ymin=..lower.., ymax=..upper..)) + 
  theme_bw()
ggplot(df, aes(x=factor(year), y=total)) + 
  geom_boxplot(linetype = "dotted", color = "red") +
  geom_boxplot(aes(ymin=..lower.., ymax=..upper..)) + 
  theme_bw()

如果这确实回答了您的问题,您应该将其作为答案提交,而不是将其编辑到您的问题中。@Gregor,谢谢。我从未使用过自我回答的方法。奇怪的是,user20650的评论被删除了。我想把评论加上标记。你在第二个箱线图的
aes
中用lower和uper是什么意思?那是很久以前的事了!我认为双周期告诉第二个方框图使用相同的数据(df)。