How to insert bold text in a cell of matplotlib table (pyplot table) ?
import matplotlib.pyplot as plt plt.table(cellText=[['my_texte_bold', 'other cell'], ['cell1', 'cell2'])
Advertisement
Answer
See the documentation for an example of how to iterate over the cells of the table and apply font properties. For example, to make the text in the first row bold, you could do the following:
import matplotlib.pyplot as plt from matplotlib.font_manager import FontProperties table = plt.table(cellText=[['my_texte_bold', 'other cell'], ['cell1', 'cell2']]) for (row, col), cell in table.get_celld().items(): if (row == 0): cell.set_text_props(fontproperties=FontProperties(weight='bold'))