【发布时间】:2021-08-10 18:32:25
【问题描述】:
我正在尝试获取一些带有误差线的堆积条形图,但是对应于一组变量的误差线没有对齐。
如果我做一个闪避位置position_dodge(按照我在这里找到的一些其他问题的例子)那么它可以工作,但不幸的是这不是我需要的...... :(
我改变了“position_dodge()”的值, 我写过: geom_errorbar(aes(ymin=gp96-sd, ymax=gp96+sd, group= type96), 而且我之前已经定义了 ymin 和 ymax 的值,但没有任何帮助...
谢谢 Vk
这是我为闪避条图尝试的一个
geom_bar(position = position_dodge(),stat="identity") +
geom_errorbar(aes(ymin=gp96-sd, ymax=gp96+sd),
position=position_dodge(), stat="identity",width=0.7,size=0.01)
这是我为堆积条形图尝试的一个
ggplot(data=dfch97,aes(y=gp96,x=sample96,fill=type96))+
geom_bar(position = position_stack(),stat="identity") +
geom_errorbar(aes(ymin=gp96-sd, ymax=gp96+sd),
position=position_dodge(), stat="identity",width=0.7,size=0.01)
我的数据框
type96<- c("co2_96","NetCH4_96h", "co2_96", "NetCH4_96h", "co2_96", "NetCH4_96h", "co2_96", "NetCH4_96h", "co2_96", "NetCH4_96h", "co2_96", "NetCH4_96h", "co2_96", "NetCH4_96h", "co2_96", "NetCH4_96h", "co2_96", "NetCH4_96h", "co2_96", "NetCH4_96h", "co2_96", "NetCH4_96h", "co2_96", "NetCH4_96h", "co2_96","NetCH4_96h")
gp96<- c( 13.066667,4.283333,11.783333,3.983333,12.616667,4.4,12.383333,4.3,12.783333,4.566667,12.466667,4.383333,11.533333,4.066667,12.816667,4.533333,12.92,4.56,12.516667,4.25,13.4,4.366667,12.45,4.316667,12.366667,4.233333)
sd<- c(2.1096603, 0.8232051, 1.553598, 0.7386925, 1.2448561, 0.6870226, 2.0311737, 0.8579044, 1.3585532, 0.7033254, 1.5933194, 0.7386925, 2.5303491, 1.1500725, 1.1373947, 0.5715476, 0.9066422, 0.5176872, 0.7026142, 0.3937004, 0.9570789, 0.6345602, 1.3003846, 0.6242329, 1.0875048, 0.3669696)```
dfch97 <- data.frame(type96, gp96, sd)
dfch97$type96=as.factor(dfch97$type96)
【问题讨论】:
-
无法重现您的示例:x=sample96 ... "sample96" 未定义。