Title: [Bug]: Font weight of label cannot be overwritten from rcParams when using mathtext · Issue #23860 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Font weight of label cannot be overwritten from rcParams when using mathtext · Issue #23860 · matplotlib/matplotlib
X Title: [Bug]: Font weight of label cannot be overwritten from rcParams when using mathtext · Issue #23860 · matplotlib/matplotlib
Description: Bug summary Font weight of x/y axis label is expected to be changed by rcParams["font.weight"] and rcParams["axes.labelweight"], and it works on first plot on the script execution. In same script, however, the updating the rcParams after...
Open Graph Description: Bug summary Font weight of x/y axis label is expected to be changed by rcParams["font.weight"] and rcParams["axes.labelweight"], and it works on first plot on the script execution. In same script, ...
X Description: Bug summary Font weight of x/y axis label is expected to be changed by rcParams["font.weight"] and rcParams["axes.labelweight"], and it works on first plot on the script executi...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/23860
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Font weight of label cannot be overwritten from rcParams when using mathtext","articleBody":"### Bug summary\r\n\r\nFont weight of x/y axis label is expected to be changed by `rcParams[\"font.weight\"]` and `rcParams[\"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.\r\n\r\n### Code for reproduction\r\n\r\nI will show two different source.\r\nBy running code below, four image will be generated.\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\n\r\nplt.rcParams[\"axes.labelweight\"] = \"normal\"\r\nplt.rcParams[\"font.weight\"] = \"normal\"\r\nplt.figure(constrained_layout=True)\r\nplt.ylabel(\"$aa$\")\r\nplt.savefig(\"1-first.png\")\r\nplt.close()\r\n\r\nplt.rcParams[\"axes.labelweight\"] = \"bold\"\r\nplt.rcParams[\"font.weight\"] = \"bold\"\r\nplt.figure(constrained_layout=True)\r\nplt.ylabel(\"$aa$\")\r\nplt.savefig(\"1-second.png\")\r\nplt.close()\r\n```\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\n\r\nplt.rcParams[\"axes.labelweight\"] = \"bold\"\r\nplt.rcParams[\"font.weight\"] = \"bold\"\r\nplt.figure(constrained_layout=True)\r\nplt.ylabel(\"$aa$\")\r\nplt.savefig(\"2-first.png\")\r\nplt.close()\r\n\r\nplt.rcParams[\"axes.labelweight\"] = \"normal\"\r\nplt.rcParams[\"font.weight\"] = \"normal\"\r\nplt.figure(constrained_layout=True)\r\nplt.ylabel(\"$aa$\")\r\nplt.savefig(\"2-second.png\")\r\nplt.close()\r\n```\r\n\r\n### Actual outcome\r\n\r\n1-first.png\r\n\r\n\r\n1-second.png\r\n\r\n\r\n2-first.png\r\n\r\n\r\n2-second.png\r\n\r\n\r\n\r\n### Expected outcome\r\n\r\n- `2-second.png` is expected to be same as `1-first.png`\r\n- `1-second.png` is expected to be same as `2-first.png`\r\n\r\n### Additional information\r\n\r\nThis is also reproduced by using `plt.rcParams.update()` and `with plt.rc_context()` instead of directly assigning to `plt.rcParams[key]`.\r\n\r\n### Operating system\r\n\r\nUbuntu 20.04 on Windows subsystem for Linux\r\n\r\n### Matplotlib Version\r\n\r\nv3.3.3, v3.5.3, HEAD (2171d95)\r\n\r\n### Matplotlib Backend\r\n\r\nagg\r\n\r\n### Python version\r\n\r\n3.8.11\r\n\r\n### Jupyter version\r\n\r\nnot using\r\n\r\n### Installation\r\n\r\npip","author":{"url":"https://github.com/ebiyu","@type":"Person","name":"ebiyu"},"datePublished":"2022-09-11T06:56:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/23860/matplotlib/issues/23860"}
| 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:cb2ea308-42f9-c16a-0355-99f56dcb9367 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D5E0:292AF3:4A183B:642673:6A5278DF |
| html-safe-nonce | 2de6d430558e5257e558d7b5553f321aa75ccc6a22305ce490eba4c675e43932 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENUUwOjI5MkFGMzo0QTE4M0I6NjQyNjczOjZBNTI3OERGIiwidmlzaXRvcl9pZCI6IjM1OTg1ODU0MzIxNjg4ODg1NDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d7d0f6fb8012f1a491f8d3ace7056b83ff177109f4c66b7c5a0d986f1be7f60e |
| hovercard-subject-tag | issue:1368852217 |
| 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/23860/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dea3f946a5ee3434b8b238f8dc9842a3c866be75e9510b701227dd8177e61a10/matplotlib/matplotlib/issues/23860 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dea3f946a5ee3434b8b238f8dc9842a3c866be75e9510b701227dd8177e61a10/matplotlib/matplotlib/issues/23860 |
| og:image:alt | Bug summary Font weight of x/y axis label is expected to be changed by rcParams["font.weight"] and rcParams["axes.labelweight"], and it works on first plot on the script execution. In same script, ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ebiyu |
| 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