Plot a pivot table inside a figure with Matplotlib in Python

Viewed 37

I want to plot a pivot table in a plt figure. The data is in a Multiindex pivot DataFrame, but when I plot it, the two index columns are shown in one column see Figure 1. I want something like the table from Figure, with combined rows for the first index and separated in three segments.

Now I'm using table, I hope there is a solution for this.

from matplotlib import pyplot as plt

fig = plt.figure(figsize=(20,25), dpi= 80)
ax_1 = fig.add_subplot()
ax_1.table(cellText = simple_count.values, rowLabels =simple_count.index, colLabels = simple_count.columns, loc= 'center' , colWidths = [.2,.2])
plt.tick_params(left=False, right=False, labelleft = False , labelbottom = False, bottom = False)
plt.show()  
0 Answers
Related