Plotting more than one legend key per group

Hi,

I've asked a similar question on stack overflow, sorry if cross-posting is discouraged.

I've been working on a ggplot2 extension package facilitating an alternative to box plots to judge the distribution of data. I called it 'quantile plot' and the idea is that you visualize different quantiles in your data using progressively lighter shades of the same color. It can be quite useful when you work with zero-inflated data.

I've made it work in principle (essentially creating a new Stat to calculate the quantiles and a new Geom based on GeomBoxplot) but am struggling with making the legend informative.

In a regular grouped boxplot using the fill aesthetic, you see one legend key per group and this is sufficient. But in this quantile plot, you need to have one legend key per group and quantile.

I need someone who's really familiar with the ggplot2 codebase to point me towards the right direction:
Should I try writing a new draw_key_* method? I couldn't make this work so far since while I am able to modify those functions to draw more than one key/group, I haven't found a way to modify the legend text correspondly (In other words I don't know how to write more than one text field per group). I'm not even sure which function writes the legend text.

I'm quite excited about the idea of writing clean ggplot2 extensions and would love if someone could point me in the right direction.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.