Open
Description
From the example in http://bxhorn.com/legends-ggplot/#managing-multiple-legends-in-a-layered-chart
# Multiple Legends
# load data
data(diamonds)
# calc quantiles with specified probabilities
new.prob <- c(0.90, 0.95, 0.99)
cut.probs <- plyr::ddply(diamonds, .(cut), numcolwise(quantile, probs = new.prob))[, c("cut", "price")]
cut.probs <- transform(cut.probs, quantile = c("P90", "P95", "P99"))
# layered graph
gg<-ggplot(diamonds, aes(cut, price)) +
geom_boxplot(aes(fill = factor(cut))) +
geom_point(data = cut.probs, aes(cut, price, color = factor(quantile)), size = 5) +
scale_fill_discrete(name = "Quality of the Cut") +
scale_color_discrete(name = "My Quantiles")
gg
plotly::ggplotly(gg)
- Multiple legend titles are clustered together
- Multiple legends are not separated
- There is extra text ",1" in legend labels