I am making a table (inspired by link and link). However how do I set up individual patches? I have a dataframe with patch "values" but I cannot do the following:
tab=ax.table(cellText=data.values, bbox=bbox, colLabels=data.columns, loc="center", cellColours = dfd_color.values, cellHatches=dfd_hatch.values, **kwargs)
My code is below:
def render_mpl_table(data, dfd_color, dfd_hatch, col_width=0.5, row_height=0.5, font_size=8,
header_color='lightgrey', row_colors=['#f1f1f2', 'w'], edge_color='w',
bbox=[0, 0, 1, 1], header_columns=0, header_height=2.0,
ax=None, **kwargs):
if ax is None:
size = (np.array(data.shape[::-1]) + np.array([0, 1])) * np.array([col_width, row_height])
size[1] += header_height - row_height
fig, ax = plt.subplots(figsize=size)
ax.axis('off')
tab=ax.table(cellText=data.values, bbox=bbox, colLabels=data.columns, loc="center", cellColours = dfd_color.values, **kwargs)
tab.auto_set_font_size(False)
tab.set_fontsize(8)
for k, cell in six.iteritems(tab._cells):
if k[0] == 0 or k[1] < header_columns:
cell.set_text_props(weight='bold', color='k')
cell.set_facecolor(header_color)
cell.set_text_props(rotation='vertical')
cell.set_height(header_height)
else:
cell.set(alpha=0.3)
cell.set_height(row_height)
cell.set(hatch = '/') #works but does not insert individual hatches
tab.auto_set_column_width(col=list(range(len(dfd['signature']))))
return ax
render_mpl_table(dfd, dfd_color, dfd_hatch, header_columns=0, header_height=2)