r - geom_errorbar and geom_facet -
the following code not display error bars:
rf.imp<- read.csv("importances_byaggregations.csv",head=true,sep=",") #changes when handling data rf.imp$flux <- as.character(rf.imp$flux) rf.imp$flux<-factor(rf.imp$flux,levels=unique(rf.imp$flux)) rf.imp$aggregation <- as.character(rf.imp$aggregation) rf.imp$aggregation<-factor(rf.imp$aggregation,levels=unique(rf.imp$aggregation)) cbbpalette <- c("#f0e442", "#cc79a7","#e69f00","#56b4e9", "#009e73") # mimicking python colors rf.imp$rel.influence<-rf.imp$rel.influence*100 rf.imp$sd<-rf.imp$sd*100 limits <- aes(ymax = rf.imp$rel.influence + rf.imp$sd, ymin=rf.imp$rel.influence - rf.imp$sd) ggplot(rf.imp, aes(variable,rel.influence,fill=variable)) + geom_bar(stat="identity",position="dodge") + scale_fill_manual(values=cbbpalette)+ theme_bw(base_size = 32, base_family = "helvetica")+ xlab("")+ ylab("variable importance (%)")+ facet_grid(aggregation~flux)+ geom_errorbar(limits, width=0.5)+ scale_y_continuous(limits=c(-10,90))+ theme(legend.position="none", strip.text.x = element_blank(), strip.text.y = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), strip.background = element_blank(), panel.border = element_rect(colour = "black"), panel.border = element_rect(colour = "black", fill=na, size=1))
i obtaine following figure, geom_facets swaped.
however, this:
am doing wrong?
thanks!
your minimal example little long me dig into, suspect problem comes using absolute (rf.imp$...
) references in error bar limits. if use
geom_errorbar(aes(ymax=rel.influence+sd, ymin=rel.influence-sd), width=0.5)
i think fix problem.
Comments
Post a Comment