R ggplot错误条不适合其条
我想要一个带有误差条的条形图 我有以下资料:R ggplot错误条不适合其条,r,ggplot2,R,Ggplot2,我想要一个带有误差条的条形图 我有以下资料: data <- read.table(text = "Write.Ratio Latency Systems ErrorBar 25 33.68947433 ZAc 0.584923265 50 35.95189364 ZAc 0.533620214 75 37.61611343 ZAc 0.478412112 100 38.94321815 ZAc 0.613659804 25 34.88948194 ZAa 0.6688
data <- read.table(text = "Write.Ratio Latency Systems ErrorBar
25 33.68947433 ZAc 0.584923265
50 35.95189364 ZAc 0.533620214
75 37.61611343 ZAc 0.478412112
100 38.94321815 ZAc 0.613659804
25 34.88948194 ZAa 0.668849228
50 37.50136427 ZAa 0.810768079
75 38.32180932 ZAa 0.855439587
100 40.11655606 ZAa 1.016661533
25 44.54909217 Z 2.743318523
50 45.11834046 Z 2.694675714
75 47.58457625 Z 3.848277026
100 51.54500237 Z 3.11271401
100 39.93495434 ZCt 1.042499708", header = TRUE)
数据我认为他们在上面的评论中告诉你的一切都是有效的。见下文
#Turn Write.Ratio into a factor
data$Write.Ratio <- as.factor(data$Write.Ratio)
data <- transform(data,Systems = reorder(Systems, order(Latency, decreasing = F)))
plot1 <- ggplot(data, aes(Write.Ratio, Latency, fill = Systems))
#Add position=position_dodge(.9) to geom_errorbar
plot1 <- plot1 + geom_bar(stat = "identity", position="dodge") +
geom_errorbar(aes(ymin=Latency-ErrorBar, ymax=Latency+ErrorBar), width = .2, position=position_dodge(.9))
plot1 <- plot1+scale_y_continuous(breaks= seq(0,60,10))+labs(x = "Write Ratio")+
scale_x_discrete(labels = seq(25,100,25))+ labs(y="Latency (ms)")
plot1 <- plot1+scale_fill_manual(values=c("#2980b9", "#F5BF00", "#66CC99", "#6c3483"))
plot1 <- plot1+theme(panel.grid.major = element_blank())
plot1 <- plot1+theme_bw()+theme(legend.position="bottom")+labs(fill="")+
theme(text = element_text(size=18))
plot1
#将Write.Ratio转换为一个因子
data$Write.Ratio我认为他们在上面的评论中告诉你的一切都是有效的。见下文
#Turn Write.Ratio into a factor
data$Write.Ratio <- as.factor(data$Write.Ratio)
data <- transform(data,Systems = reorder(Systems, order(Latency, decreasing = F)))
plot1 <- ggplot(data, aes(Write.Ratio, Latency, fill = Systems))
#Add position=position_dodge(.9) to geom_errorbar
plot1 <- plot1 + geom_bar(stat = "identity", position="dodge") +
geom_errorbar(aes(ymin=Latency-ErrorBar, ymax=Latency+ErrorBar), width = .2, position=position_dodge(.9))
plot1 <- plot1+scale_y_continuous(breaks= seq(0,60,10))+labs(x = "Write Ratio")+
scale_x_discrete(labels = seq(25,100,25))+ labs(y="Latency (ms)")
plot1 <- plot1+scale_fill_manual(values=c("#2980b9", "#F5BF00", "#66CC99", "#6c3483"))
plot1 <- plot1+theme(panel.grid.major = element_blank())
plot1 <- plot1+theme_bw()+theme(legend.position="bottom")+labs(fill="")+
theme(text = element_text(size=18))
plot1
#将Write.Ratio转换为一个因子
数据$Write.Ratio生成Write.Ratio
和因子,然后使用回避。看#aosmith我看过这篇文章,这其实不是同一个错误,我以前尝试过这个解决方案,但没有解决它。你是否把Write.Ratio
作为一个因素?另请参见它应该使用position=position\u dodge(0.9)
。如果没有,请告诉我们您尝试了什么。在我向geom_errorbar添加一些属性之前,比如bellow geom_errorbar(aes(ymin=Latency errorbar,ymax=Latency+errorbar),width=.2,position=position_dodge(.9))MakeWrite.Ratio
和factor,然后使用Dodding。看#aosmith我看过这篇文章,这其实不是同一个错误,我以前尝试过这个解决方案,但没有解决它。你是否把Write.Ratio
作为一个因素?另请参见它应该使用position=position\u dodge(0.9)
。如果没有,请告诉我们您尝试了什么。在我向geom_errorbar添加一些属性之前,比如bellow geom_errorbar(aes(ymin=Latency errorbar,ymax=Latency+errorbar),width=.2,position=position_dodge(.9)),是的,它很有帮助并且有效!。使问题得以解决的一行是这个数据$Write.Ratio@IbrahimEL Sanosi Addlimits=c(0,61)
到scale\u y\u continuous
是的,它有帮助而且有效!。使问题得以解决的一行数据是$Write.Ratio@IbrahimEL Sanosi Addlimits=c(0,61)
到scale\u y\u continuous