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]: Setting font.sans-serif is impossible by the intended way using matplotlib.rc because it contains a hyphen. #30021

Closed
Milestone
@matj1

Description

@matj1

Bug summary

The functionsmatplotlib.rc andmatplotlib.pyplot.rc process settings given as named parameters. Named parameters can't contain hyphens; therefore, it is impossible to setfont.sans-serif so because it contains a hyphen.

It is possible to set the parameter by different means, but this seems like the main way, so I consider that it does not work a significant shortcoming. How else this parameter can be set:

  • matplotlib.rcParams["font.sans-serif"] = "Fira Sans"
  • matplotlib.rc("font", **{"sans-serif": "Fira Sans"})

Code for reproduction

frommatplotlibimportrcrc("font",sans-serif="Fira Sans")

Actual outcome

>>> from matplotlib import rc>>> rc("font", sans-serif="Fira Sans")  File "<python-input-1>", line 1    rc("font", sans-serif="Fira Sans")               ^^^^^^^^^^^SyntaxError: expression cannot contain assignment, perhaps you meant "=="?

Expected outcome

I think that that the parameter is namedfont.sans-serif is a mistake, and it should be named something likefont.sans_serif with an underscore. It may be too late to change that, but an alias would work.rc already has aliases likelwlinewidth,lslinestyle,ccolor. I expect that there would be an alias likesanssans-serif so I could userc("font", sans="Fira Sans").

Additional information

No response

Operating system

No response

Matplotlib Version

3.10.1

Matplotlib Backend

No response

Python version

Python 3.13.3

Jupyter version

No response

Installation

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp