审美把控失误
Error with aesthetics control
我有数据框
pGi.Fi <- data.frame(
Metadata_Well = c("D01", "F01"),
Freq = c("0.3789279","0.4191564"),
control = c("Scramble2","Scramble2"))
置信区间向量 CI <- c(0.03222640,0.03196117)
此代码用于生成带有 error_bar
的条形图
limits <- aes(ymax = Freq+CI, ymin = Freq-CI)
dodge <- position_dodge(width=0.9)
bp <- ggplot(data=pGi.Fi, aes(x=Metadata_Well, y=Freq, fill=control)) +
geom_bar(position = "dodge", stat="identity") +
geom_bar(position=dodge) +
geom_errorbar(limits, position=dodge, width=0.25) +
scale_fill_grey()
我遇到了这个错误
Aesthetics must either be length one, or the same length as the dataProblems:Metadata_Well, Freq
感谢您的回答
无法准确重现您的错误,但我认为部分问题与您传递美学的方式有关?一般来说,最好在传递给 ggplot 的数据上引用变量,而不是混合一些对数据框的引用和其他对本地环境中变量的引用。我还挂断了你的一个 geom_bar()
电话,因为它似乎是重复的。
pGi.Fi <- data.frame(
Metadata_Well = c("D01", "F01"),
Freq = c(0.3789279,0.4191564),
control = c("Scramble2","Scramble2"),
ci = c(0.03222640,0.03196117)
)
dodge <- position_dodge(width=0.9)
bp <- ggplot(
data = pGi.Fi,
aes(
x = Metadata_Well,
y = Freq,
fill = control
)) +
geom_bar(
position = "dodge",
stat = "identity"
) +
geom_errorbar(
aes(
ymax = Freq+CI,
ymin = Freq-CI
),
position = dodge,
width = 0.25
) +
scale_fill_grey()
bp
我有数据框
pGi.Fi <- data.frame(
Metadata_Well = c("D01", "F01"),
Freq = c("0.3789279","0.4191564"),
control = c("Scramble2","Scramble2"))
置信区间向量 CI <- c(0.03222640,0.03196117)
此代码用于生成带有 error_bar
的条形图limits <- aes(ymax = Freq+CI, ymin = Freq-CI)
dodge <- position_dodge(width=0.9)
bp <- ggplot(data=pGi.Fi, aes(x=Metadata_Well, y=Freq, fill=control)) +
geom_bar(position = "dodge", stat="identity") +
geom_bar(position=dodge) +
geom_errorbar(limits, position=dodge, width=0.25) +
scale_fill_grey()
我遇到了这个错误
Aesthetics must either be length one, or the same length as the dataProblems:Metadata_Well, Freq
感谢您的回答
无法准确重现您的错误,但我认为部分问题与您传递美学的方式有关?一般来说,最好在传递给 ggplot 的数据上引用变量,而不是混合一些对数据框的引用和其他对本地环境中变量的引用。我还挂断了你的一个 geom_bar()
电话,因为它似乎是重复的。
pGi.Fi <- data.frame(
Metadata_Well = c("D01", "F01"),
Freq = c(0.3789279,0.4191564),
control = c("Scramble2","Scramble2"),
ci = c(0.03222640,0.03196117)
)
dodge <- position_dodge(width=0.9)
bp <- ggplot(
data = pGi.Fi,
aes(
x = Metadata_Well,
y = Freq,
fill = control
)) +
geom_bar(
position = "dodge",
stat = "identity"
) +
geom_errorbar(
aes(
ymax = Freq+CI,
ymin = Freq-CI
),
position = dodge,
width = 0.25
) +
scale_fill_grey()
bp