I´d made a Y-maze
experiment, where values goes to 0 (total preference to stimulus A) to 1 (total preference to stimulus B), index response is calculated as : # flies on stimulus B/(# flies stimulus A+B)
A 0.5 value means no differential election (a 50-50 random distribution)
I need to make a diverging plot with means very similar to this with ggplot2
:
NOTE: y-values starts from 0.5, what i want to make is the horizontal line in y=0.5, and that the bars starts from 0.5
here´s some of my data:
data<-data.frame(Line= c(21,181,208,217), mean= c(0.584, 0.897, 0.345, 0.67)
data$Linea<-as.factor(data$Line)
What I have tried is this code:
data$category<- ifelse(data$mean >0.5, "grape","apple")
ggplot(data,aes(x = Line ,y =mean)) +
geom_bar(aes(fill = category),stat = "identity") +
labs(title= "Diverging Bars")+
ylim(0,1)+ geom_hline(yintercept = 0.5)