ggplot错误栏问题

时间:2015-12-11 23:04:27

标签: r graphics ggplot2 errorbar

好的,我有两个问题,我无法弄清楚如何修复:

1)误差线不会与图表上的条形对齐。 2)条纹的颜色用我想要的颜色勾勒出来,但由于某种原因用黑色填充。

<header>
</header>

<div class="intro">




</div>

我的数据框是“Cycle1”...我很抱歉不知道如何正确发布数据。

Oreo_Cycle1 <- Cycle1[Cycle1$Food_Type=="Oreo",]
Chow_Cycle1 <- Cycle1[Cycle1$Food_Type=="Chow",]
#Oreo graph
Oreop <- ggplot(Oreo_Cycle1, aes(as.factor(Oreo_Cycle1$Time_Point),           
Oreo_Cycle1$Amount, color=Oreo_Cycle1$Treatment, ymax=Oreo_Cycle1$Amount +  
Oreo_Cycle1$SEM, ymin=Oreo_Cycle1$Amount - Oreo_Cycle1$SEM))

Oreop + geom_bar(position="dodge", width=0.5, stat="identity") +   
scale_color_manual("Treatment Group", labels=c("Control", "HD+S", "HD+S+E"),  
values=c("#CC0000","#00CC00","#0000CC")) + xlab("Timepoint (h)") + ylab("HP 
consumed (g)") + geom_errorbar(color="black")

1 个答案:

答案 0 :(得分:2)

int** twoDimensionalArray = new int*[rowCount]; for (int i = 0; i < rowCount; ++i) { twoDimensionalArray[i] = new int[colCount]; } 仅针对酒吧的外部。 color确定其中的颜色。

fill

我确定你已经注意到了,但我简化了你的代码。每次拨打电话时都不需要指定ggplot(Oreo_Cycle1, aes(x = as.factor(Time_Point), y = Amount, fill = Treatment, ymax=(Amount + SEM), ymin=(Amount - SEM)) + geom_bar(position="dodge", width=0.5, stat="identity") + scale_fill_manual("Treatment Group", labels=c("Control", "HD+S", "HD+S+E"), values=c("#CC0000","#00CC00","#0000CC")) + xlab("Timepoint (h)") + ylab("HP consumed (g)") + geom_errorbar(color="black")