【发布时间】:2022-01-05 20:46:43
【问题描述】:
有人可以帮我解决这个问题吗?误差线未与列正确对齐。
ggplot (data=nitrate_meso00, aes(x = Date,
y = mean_rr,
fill = treatment,
ymin = lci_rr+mean_rr,
ymax =uci_rr+ mean_rr)) +
theme_bw() +
theme(panel.grid = element_blank ()) +
# manually setting the width means we will have to tell geom_errorbar() about the new width
geom_bar(stat = "identity", position = "dodge", width = 8) +
theme(legend.title = element_blank()) +
theme(legend.position = "right")+
geom_errorbar(width = 8,position = position_dodge(0.5))
【问题讨论】:
-
您好,您可能需要发布您的数据以供人们帮助。尝试使用
dput(nitrate_meso00)或其他方法来提供您的结构。 -
这能回答你的问题吗? ggplot2 - Bars non-aligned to error bars
-
我认为 OP 在最初的
ggplot(aes())调用中使用fill = treatment实现了上述问题中的解决方案。我认为剩下的问题是条形图和误差线与中心的相对位移(如下所示)。非常方便注意,尽管将它们分组确实可以正确排列躲避的元素。