Title: [Bug]: Setting font.sans-serif is impossible by the intended way using matplotlib.rc because it contains a hyphen. · Issue #30021 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Setting font.sans-serif is impossible by the intended way using matplotlib.rc because it contains a hyphen. · Issue #30021 · matplotlib/matplotlib
X Title: [Bug]: Setting font.sans-serif is impossible by the intended way using matplotlib.rc because it contains a hyphen. · Issue #30021 · matplotlib/matplotlib
Description: Bug summary The functions matplotlib.rc and matplotlib.pyplot.rc process settings given as named parameters. Named parameters can't contain hyphens; therefore, it is impossible to set font.sans-serif so because it contains a hyphen. It i...
Open Graph Description: Bug summary The functions matplotlib.rc and matplotlib.pyplot.rc process settings given as named parameters. Named parameters can't contain hyphens; therefore, it is impossible to set font.sans-ser...
X Description: Bug summary The functions matplotlib.rc and matplotlib.pyplot.rc process settings given as named parameters. Named parameters can't contain hyphens; therefore, it is impossible to set font.sans...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30021
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Setting font.sans-serif is impossible by the intended way using matplotlib.rc because it contains a hyphen.","articleBody":"### Bug summary\n\nThe functions `matplotlib.rc` and `matplotlib.pyplot.rc` process settings given as named parameters. Named parameters can't contain hyphens; therefore, it is impossible to set `font.sans-serif` so because it contains a hyphen.\n\nIt 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:\n- `matplotlib.rcParams[\"font.sans-serif\"] = \"Fira Sans\"`\n- `matplotlib.rc(\"font\", **{\"sans-serif\": \"Fira Sans\"})`\n\n\n### Code for reproduction\n\n```Python\nfrom matplotlib import rc\nrc(\"font\", sans-serif=\"Fira Sans\")\n```\n\n### Actual outcome\n\n```\n\u003e\u003e\u003e from matplotlib import rc\n\u003e\u003e\u003e rc(\"font\", sans-serif=\"Fira Sans\")\n File \"\u003cpython-input-1\u003e\", line 1\n rc(\"font\", sans-serif=\"Fira Sans\")\n ^^^^^^^^^^^\nSyntaxError: expression cannot contain assignment, perhaps you meant \"==\"?\n```\n\n### Expected outcome\n\nI think that that the parameter is named `font.sans-serif` is a mistake, and it should be named something like `font.sans_serif` with an underscore. It may be too late to change that, but an alias would work. `rc` already has aliases like `lw` → `linewidth`, `ls` → `linestyle`, `c` → `color`. I expect that there would be an alias like `sans` → `sans-serif` so I could use `rc(\"font\", sans=\"Fira Sans\")`.\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.10.1\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\nPython 3.13.3\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nNone","author":{"url":"https://github.com/matj1","@type":"Person","name":"matj1"},"datePublished":"2025-05-06T17:18:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/30021/matplotlib/issues/30021"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6b435e6c-43c7-848f-ae5f-31384e96678e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BE4C:14A013:26A527B:343112D:6A539E90 |
| html-safe-nonce | 83de5ebd2f7fc9b02ab1b62e289ee17b964b721fe17f8330a255629b9f471554 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTRDOjE0QTAxMzoyNkE1MjdCOjM0MzExMkQ6NkE1MzlFOTAiLCJ2aXNpdG9yX2lkIjoiODAwNDcwMTA3ODcyMDU4NTM2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 857d0885e6e8a3bc19f9e453af9dc5999c8e9a372da7e02760ad0db26f556610 |
| hovercard-subject-tag | issue:3043509664 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/30021/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8514665298a769b91478a6708df13b6822025b07a2007a14fa5992fba1908778/matplotlib/matplotlib/issues/30021 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8514665298a769b91478a6708df13b6822025b07a2007a14fa5992fba1908778/matplotlib/matplotlib/issues/30021 |
| og:image:alt | Bug summary The functions matplotlib.rc and matplotlib.pyplot.rc process settings given as named parameters. Named parameters can't contain hyphens; therefore, it is impossible to set font.sans-ser... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | matj1 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width