Skip to content

Instantly share code, notes, and snippets.

@crazyhottommy
Created June 7, 2016 21:33
Show Gist options
  • Save crazyhottommy/01ae8c7b5f348880d026eeb05f5d65b2 to your computer and use it in GitHub Desktop.
Save crazyhottommy/01ae8c7b5f348880d026eeb05f5d65b2 to your computer and use it in GitHub Desktop.
boxplot-label-mean
## http://stackoverflow.com/questions/19876505/boxplot-show-the-value-of-mean
## plot adding mean value
ggplot(NLR.tidy, aes(x=NLR, y=ratio_value, color= NLR,fill= NLR)) +
geom_point(position=position_jitterdodge(dodge.width=0.9)) +
geom_boxplot(fill="white", alpha=0.1, outlier.colour = NA,
position = position_dodge(width=0.9)) +
coord_cartesian(ylim = c(-0.5, 15)) +
stat_summary(fun.y = mean, geom="point",colour="black", size=3, show.legend = FALSE) +
stat_summary(fun.y=mean, colour="red", geom="text", show.legend =FALSE,
vjust=-0.7, aes( label=round(..y.., digits=1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment