I made a small reproducible program, where you will see the title
in bold font, but the label
in normal font:
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
observed = np.array([28, 15, 21, 23, 17, 22, 19, 19, 24, 27, 20, 21, 25, 25, 16, 20, 23])
fig, ax = plt.subplots(figsize=(4, 2))
sns.histplot(ax = ax, x = list(observed), label = "observed data")
ax.set_title("Observed data", fontweight='bold')
ax.legend()
plt.show()
I tried to set the label
in bold by putting the same code fontweight='bold'
(after the label =
term) inside the sns.histplot
instruction, but this leads to an error:
sns.histplot(ax = ax, x = list(observed), label = "observed data", fontweight='bold')
Okay, I admit that it wasn't a very smart attempt, but I don't know how to get the label in bold, in a simple way... Could someone help me to do so?
Adjust the font properties of the legend:
ax.legend(prop={"weight": "bold"})
https://matplotlib.org/3.5.0/api/_as_gen/matplotlib.pyplot.legend.html