Closed
Description
Related to matplotlib/matplotlib#1257.
This is a feature available in Excel and OpenOffice 3.3.
I think there may be a simple way to do it with matplotlib's table to construct the hierarchical axes labels. I'm not an expert in matplotlib or pandas, but I've cobbled together a small demo:
import itertools
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
row_labels = itertools.product(['ASub', 'DSub'], ['LD', 'LS'], ['GD', 'GS'],
['Attn', 'Dist'])
midx = pd.MultiIndex.from_tuples([row for row in row_labels],
names=['Group', 'Local', 'Global', 'Attn'])
df = pd.DataFrame({'mean': np.random.rand(16)}, index=midx)
ax = df.plot(kind='bar')
ax.xaxis.set_visible(False)
cell_text = np.array(df.index.tolist()).T
ax.table(cellText=cell_text, rowLabels=df.index.names, cellLoc = 'center')
plt.subplots_adjust(bottom=0.2)
plt.show()
There's probably a smarter way to populate the table in order to place the labels at the center of the merged cells as well as fix the spacing clashes.