Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Labels
Description
Bug summary
Font weight of x/y axis label is expected to be changed byrcParams["font.weight"]
andrcParams["axes.labelweight"]
, and it works on first plot on the script execution. In same script, however, the updating the rcParams after first plot doesn't take effect. The problem only occurs when the label uses mathtext.
Code for reproduction
I will show two different source.
By running code below, four image will be generated.
importmatplotlib.pyplotaspltplt.rcParams["axes.labelweight"]="normal"plt.rcParams["font.weight"]="normal"plt.figure(constrained_layout=True)plt.ylabel("$aa$")plt.savefig("1-first.png")plt.close()plt.rcParams["axes.labelweight"]="bold"plt.rcParams["font.weight"]="bold"plt.figure(constrained_layout=True)plt.ylabel("$aa$")plt.savefig("1-second.png")plt.close()
importmatplotlib.pyplotaspltplt.rcParams["axes.labelweight"]="bold"plt.rcParams["font.weight"]="bold"plt.figure(constrained_layout=True)plt.ylabel("$aa$")plt.savefig("2-first.png")plt.close()plt.rcParams["axes.labelweight"]="normal"plt.rcParams["font.weight"]="normal"plt.figure(constrained_layout=True)plt.ylabel("$aa$")plt.savefig("2-second.png")plt.close()
Actual outcome
Expected outcome
2-second.png
is expected to be same as1-first.png
1-second.png
is expected to be same as2-first.png
Additional information
This is also reproduced by usingplt.rcParams.update()
andwith plt.rc_context()
instead of directly assigning toplt.rcParams[key]
.
Operating system
Ubuntu 20.04 on Windows subsystem for Linux
Matplotlib Version
v3.3.3, v3.5.3, HEAD (2171d95)
Matplotlib Backend
agg
Python version
3.8.11
Jupyter version
not using
Installation
pip