def task_table_plot(task_data): """ Plot task table, save in png file. :param task_data: dataframe from get_task_table(). """ groups = task_data.Group.values task_no_group = task_data.drop('Group', axis=1) nrows, ncols = task_no_group.shape width, height = 1.0 / ncols, 1.0 / nrows fig, ax = plt.subplots(figsize=(1, nrows*0.25)) ax.set_axis_off() tbl = Table(ax) tbl.auto_set_font_size(False) # Columns width for non-auto-width columns col_widths = [1, 1, 0.5, 1, 0.7, 0.7, 0.7, 0.7, 0.7] palette = get_palette() fontcolor = 'w' for (i, j), val in np.ndenumerate(task_no_group): fc = palette[groups[i]] fontsize = 10 if j < 2: loc = 'left' font_family = None if j == 0: fontsize = 9 else: loc = 'center' #font_family = 'DINPro' if j > 3: fontsize = 9 tbl.add_cell(i, j, col_widths[j], height, text=val, loc=loc, facecolor=fc, edgecolor=fontcolor) cell = tbl.get_celld()[(i, j)] cell.set_linewidth(0.5) cell.set_text_props(color=fontcolor, family=font_family, weight='bold', fontsize=fontsize) # Column Labels... for j, label in enumerate(task_no_group.columns): tbl.add_cell(-1, j, col_widths[j], height*0.8, text=label, loc='center', facecolor='gray', edgecolor='w') cell = tbl.get_celld()[(-1, j)] cell.set_linewidth(0.5) cell.set_text_props(color=fontcolor, weight='bold', family='Verdana', fontsize=9) tbl._autoColumns = [0, 1] tbl.scale(1, 1.5) # scale y to cover blank in the bottom ax.add_table(tbl) ax.margins(0, 0) fig.savefig('img/task_table', bbox_inches='tight', pad_inches=0.1, dpi=200)
def task_table_plot(task_data): """ Plot task table, save in png file. :param task_data: dataframe from get_task_table(). """ groups = task_data.Group.values task_no_group = task_data.drop('Group', axis=1) nrows, ncols = task_no_group.shape width, height = 1.0 / ncols, 1.0 / nrows fig, ax = plt.subplots(figsize=(1, nrows*0.25)) ax.set_axis_off() tbl = Table(ax) tbl.auto_set_font_size(False) # Columns width for non-auto-width columns col_widths = [1, 1, 0.5, 1, 0.7, 0.7, 0.7, 0.7, 0.7] palette = get_palette() fontcolor = 'w' for (i, j), val in np.ndenumerate(task_no_group): fc = palette[groups[i]] fontsize = 10 if j < 2: loc = 'left' font_family = None if j == 0: fontsize = 9 else: loc = 'center' font_family = 'DINPro' if j > 3: fontsize = 9 tbl.add_cell(i, j, col_widths[j], height, text=val, loc=loc, facecolor=fc, edgecolor=fontcolor) cell = tbl.get_celld()[(i, j)] cell.set_linewidth(0.5) cell.set_text_props(color=fontcolor, family=font_family, weight='bold', fontsize=fontsize) # Column Labels... for j, label in enumerate(task_no_group.columns): tbl.add_cell(-1, j, col_widths[j], height*0.8, text=label, loc='center', facecolor='gray', edgecolor='w') cell = tbl.get_celld()[(-1, j)] cell.set_linewidth(0.5) cell.set_text_props(color=fontcolor, weight='bold', family='Verdana', fontsize=9) tbl._autoColumns = [0, 1] tbl.scale(1, 1.5) # scale y to cover blank in the bottom ax.add_table(tbl) ax.margins(0, 0) fig.savefig('img/task_table', bbox_inches='tight', pad_inches=0.1, dpi=200)