Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: Font weight of label cannot be overwritten from rcParams when using mathtext #23860

Open
@ebiyu

Description

@ebiyu

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

1-first.png
1-first

1-second.png
1-second

2-first.png
2-first

2-second.png
2-second

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp