Friday, 30 August 2013

Prevent inclusion of mean in boxplot legend

Prevent inclusion of mean in boxplot legend

In ggplot2 boxplot with added mean, is there a way to prevent the mean
from being included with the legend? I must use a large point size and
find its inclusion in the legend distracting. The conceptually closest
problem I could find, for removing the slash from the legend of outlined
bar charts, is at
http://www.cookbook-r.com/Graphs/Legends_%28ggplot2%29/#modifying-the-legend-box
That solution uses geom_bar twice to overlay one plot on another, the
second, outlined bar chart, without a legend. But is there a solution for
preventing the mean from appearing in the boxplot legend?
ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) +
geom_boxplot() +
stat_summary(fun.y=mean, colour="darkred", geom="point", shape=18, size=3) +
# idea from above website
geom_boxplot(show_guide=FALSE)
Thank you.

No comments:

Post a Comment