[英]Error with position dodge in ggplot2
I'm currently facing an error using ggplot2. 我目前在使用ggplot2时遇到错误。 I want to create a barplot with standard error bar using this data frame :
我想使用此数据框创建带有标准错误栏的条形图:
mean se pattern quality
1 54.955357 19.792315 spread good
2 54.506944 18.580981 clumped good
3 29.604167 14.937291 centered good good
5 23.300595 14.336305 spread bad
6 8.371528 5.960366 clumped bad
7 16.364583 11.525207 centered good bad
8 7.062500 11.125915 centered bad bad
I use this formula to create my bar plot : 我使用以下公式创建条形图:
ggplot(table, aes(x=pattern, y=mean, fill=quality))+
geom_bar(position="dodge")+
geom_errorbar(aes(ymin=mean-se, ymax=mean+se,
width=0.2, position=position_dodge(0.9)))
But when I run it, the window that should have my barplot appears blank and this error message pops up 但是当我运行它时,应该带有我的barplot的窗口显示为空白,并且弹出此错误消息
Don't know how to automatically pick scale for object of type proto/environment. Defaulting to continuous
Error : Aesthetics must either be length one, or the same length as the dataProblems:position_dodge(0.9)
When I try to run it without position=position_dodge(0.9)
a bar plot appears but the bars are between each bar of means and not in the middle. 当我尝试在没有
position=position_dodge(0.9)
的情况下运行它时,会出现一个条形图,但这些条形位于均值的每个条形之间,而不在中间。
I've tried several value for dodge
and other things but i'm running out of ideas. 我已经尝试了
dodge
和其他东西的几种价值,但我的想法已经用完了。
I got a warning that "stat_identity" (mapping to value, not count) was applied. 我收到一条警告,指出已应用“ stat_identity”(映射到值,而不是计数)。 To prevent that warning, simply add
stat="identity"
to the geom. 为了防止该警告,只需将
stat="identity"
添加到geom。
te <- c("val mean se pattern quality",
"1 54.955357 19.792315 spread good",
"2 54.506944 18.580981 clumped good",
"3 29.604167 14.937291 centered_good good",
"5 23.300595 14.336305 spread bad",
"6 8.371528 5.960366 clumped bad",
"7 16.364583 11.525207 centered_good bad",
"8 7.062500 11.125915 centered_bad bad")
df <- read.table(text=te, header=T)
require(ggplot2)
ggplot(df, aes(x=pattern, y=mean, fill=quality))+
geom_bar(position="dodge", stat="identity")+
geom_errorbar(aes(ymin=mean-se, ymax=mean+se),
width=0.2, position=position_dodge(0.9))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.