Legend or Key for charts with colored groups

Bug #339767 reported by Michael Wayne Goodman
2
Affects Status Importance Assigned to Milestone
Cairo Plot
In Progress
Medium
Rodrigo Moreira Araújo

Bug Description

When I make a bar chart, I like the ability to compare different sources of data with groups. For example, here is a chart I'm using for:

cairoplot.vertical_bar_plot('barchart.png',
  [ [0.87, 0.82], [0.83, 0.50], [0.70, 0.11] ],
  340, 280, border = 10, grid = True,
  x_labels = ['Parses', 'Generates', 'Generates Original'],
  y_labels = ['%d%%' % i for i in range(0,110,10)],
  y_bounds = (0,1) )

I've attached the png file generated so you can see what I mean.

Which makes a nice bar chart with three groups with two bars each. I can label the groups (as I have done here), but I cannot label what each color means. I would like to have a legend on some side of the chart with each color in a box and a label next to it. This could be defined as:

legend = ['Grammar 1', 'Grammar 2']

where 'Grammar 1' (yellow) is the source for the 0.87, 0.83, and 0.70 in the data, and 'Grammar 2' (blue) is for the 0.82, 0.50, and 0.11.

Revision history for this message
Michael Wayne Goodman (goodmami) wrote :
Revision history for this message
Rodrigo Moreira Araújo (alf-rodrigo) wrote :

Nice observation.
I don't know you've seen but the ScatterPlot, DotLinePlot and FunctionPlot classes already support that. Whenever a user passes data using dictionaries, the dictionaries keys are plotted on a little box on the upper corner.

For BarPlot charts it won't be possible to use dictionaries. I'll give it further studying though. If I don't find a way to maintain code compatibility, I believe I'll follow your advice and add a new parameter to the function. Something like group_legend or group_names.

Changed in cairoplot:
assignee: nobody → alf-rodrigo
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Michael Wayne Goodman (goodmami) wrote :

I would suggest not calling it "group_(something)" because "group" is already used in reference to those bars that are next to each other (eg. [0.87, 0.82] in the example above), although that terminology might only be used in the documentation and examples rather than code. Perhaps "data source" is more descriptive? Alternatively, call it a "group", but then find a different word for what was a "group" before, like "comparison" or something.

Changed in cairoplot:
importance: High → Medium
Revision history for this message
Rodrigo Moreira Araújo (alf-rodrigo) wrote :

Committed a partial solution on revision 32.
Through the parameter series_labels (this name was selected to maintain the relation with the ScatterPlot) the user might pass a list of strings. These will be plotted on a box on the right upper corner of the image displaying which color represents each of the strings.
It's still partial because the user cannot define the plotting position of the box.

Changed in cairoplot:
status: Confirmed → In Progress
Revision history for this message
Rodrigo Moreira Araújo (alf-rodrigo) wrote :

My mistake, the partial solution was committed on revision 33.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.