0

How can I format Matplotlib plots on multi-indexed data to resemble Excel's PivotChart axis layout? Excel's PivotChart feature groups similar axis labels together, whereas MPL labels each tick individually as (Index1,Index2). Using the Sample Data, I've provided the outputs for both Excel and MPL; notice how Index1 is grouped in the Excel chart, but not in the MPL plot.

data = {
  'Index1': {0: 'A', 1: 'A', 2: 'B', 3: 'B'},
  'Index2': {0: 1, 1: 2, 2: 1, 3: 2},
  'Value': {0: 50, 1: 100, 2: 50, 3: 100}
}

Matplotlib Chart

Excel Chart

Does anyone have a solution? Ideally, the number of multi-index levels will not matter. Thanks for the help!

Toxantron
  • 2,218
  • 12
  • 23
  • Please make sure to format code blocks with 4 spaces indentation. – Toxantron Apr 17 '16 at 00:46
  • 1
    Possible duplicate of [How to add group labels for bar charts in matplotlib?](http://stackoverflow.com/questions/19184484/how-to-add-group-labels-for-bar-charts-in-matplotlib) I am not yet aware that this has made it into mpl as a feature however. – ljetibo Apr 17 '16 at 01:10

0 Answers0