6

I Have a CM and want the text to be bold. So all the numbers and the labels as well. Heres the code:

array = np.array([[1003, 32], [30, 51]])
labels = np.array(["Label 1", "Label 2"])
disp = ConfusionMatrixDisplay(confusion_matrix=array, display_labels=labels)

disp = disp.plot(include_values=True, cmap="Reds", ax=None, xticks_rotation="horizontal")
plt.show()

Is there any easy way to change it to a bold style?

hafnerl
  • 123
  • 1
  • 5
  • Does this answer your question? [How to change the font size on a matplotlib plot](https://stackoverflow.com/questions/3899980/how-to-change-the-font-size-on-a-matplotlib-plot) – Mr. T Feb 26 '21 at 09:45

1 Answers1

6

This kind of plot relies on the library matplotlib that I guess you imported as

import matplotlib.pyplot as plt

I would suggest you to set the params for the font before your plot.

font = {'family' : 'normal',
    'weight' : 'bold',
    'size'   : 22}
plt.rc('font', **font)

If interested in more detail take a look at that question How to change the font size on a matplotlib plot

Lorenzo Vitali
  • 310
  • 3
  • 9