Fwd: Custom legend in ggplot - stat_summary shape and geom_bar fill

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Fwd: Custom legend in ggplot - stat_summary shape and geom_bar fill

Hi Everyone,

I am spending far to much time on this problem.  Every post I read gets me
closer to a solution,  but I am still not quite there.

I am trying to create a bar plot similar to the one below:


My code is as follows:

q92 <- function(x) {quantile(x,probs=0.92,na.rm = TRUE)}

ggplot(River_Df, aes(x= reorder(Name, ECOLI, FUN = q92, order=TRUE),
  geom_bar(stat="summary",fun.y="median",aes(colour = "Median"),
  stat_summary(fun.y=q92, geom ="point",size=3, shape=18,aes(colour ="95th
Percentile"),show_guide = FALSE)+
  theme(axis.text.x = element_text(angle = 90, hjust = 1))+
  xlab(paste("Monitored River Sites
  ylab("E. coli (cfu/100mL)")

As you can see, I end up with two legend items, '95th Percentile' and
'Median'.  However, I would like the '95th Percentile' item to be a darkred
diamond with no background.

Any ideas how to do this?  The dataset is attached below:

Datafile.csv <http://r.789695.n4.nabble.com/file/t124289/Datafile.csv>

Thanks in advance for your help.


        [[alternative HTML version deleted]]

[hidden email] mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.