Title: [Bug]: rcParams['legend.loc'] can't use float-tuple like kwarg legend(loc...) · Issue #22338 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: rcParams['legend.loc'] can't use float-tuple like kwarg legend(loc...) · Issue #22338 · matplotlib/matplotlib
X Title: [Bug]: rcParams['legend.loc'] can't use float-tuple like kwarg legend(loc...) · Issue #22338 · matplotlib/matplotlib
Description: Bug summary We can now use a (x,y) argument for plt.legend(loc=(x,y)), but using the tuple as a value for rcParams['legend.loc'] fails. Code for reproduction import matplotlib.pyplot as plt import matplotlib as mpl xs, ys = [1,2,3], [2,3...
Open Graph Description: Bug summary We can now use a (x,y) argument for plt.legend(loc=(x,y)), but using the tuple as a value for rcParams['legend.loc'] fails. Code for reproduction import matplotlib.pyplot as plt import ...
X Description: Bug summary We can now use a (x,y) argument for plt.legend(loc=(x,y)), but using the tuple as a value for rcParams['legend.loc'] fails. Code for reproduction import matplotlib.pyplot as plt...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22338
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: rcParams['legend.loc'] can't use float-tuple like kwarg legend(loc...)","articleBody":"### Bug summary\n\nWe can now use a (x,y) argument for `plt.legend(loc=(x,y))`,\r\nbut using the tuple as a value for rcParams['legend.loc'] fails. \r\n\r\n\n\n### Code for reproduction\n\n```python\nimport matplotlib.pyplot as plt\r\nimport matplotlib as mpl\r\nxs, ys = [1,2,3], [2,3,1]\r\n\r\nfig, ax = plt.subplots(3)\r\n\r\nax[0].scatter(xs, ys, label='loc-tuple-arg')\r\nax[0].legend(loc=(1.1, .5)) # works\r\n\r\nax[1].scatter(xs, ys, label='loc-rcparam-tuple')\r\nmpl.rcParams['legend.loc'] = (0.9, .7)\r\nax[1].legend() # fails w/o documentation\r\n\r\nax[2].scatter(xs, ys, label='loc-rcparam-str(tuple)')\r\nmpl.rcParams['legend.loc'] = '(.8, .3)'\r\nax[2].legend() # fails with documentation\n```\n\n\n### Actual outcome\n\nSetting rcParams['legend.loc'] to a tuple fails with \r\n\r\n\u003e AttributeError: 'tuple' object has no attribute 'lower'\r\n\r\nsetting rcParams['legend.loc'] to the string representation of a tuple fails with a list of supported values. \n\n### Expected outcome\n\nIdeally rcParams['legend.loc'] would apply a tuple the same way the kwarg does. \r\n\r\nSecond best would be a bit more documentation; 1) reporting the list of supported strings for any un-interpretable value, and 2) mentioning in the default matplotlibrc that only a set of strings are supported. \n\n### Additional information\n\nI believe the `loc` kwarg originally only took string values, but that seems to have been at least a major version ago. \n\n### Operating system\n\nUbuntu\n\n### Matplotlib Version\n\n3.3.4\n\n### Matplotlib Backend\n\nTkAgg\n\n### Python version\n\nPython 3.9.7\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/cphlewis","@type":"Person","name":"cphlewis"},"datePublished":"2022-01-27T23:09:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/22338/matplotlib/issues/22338"}
| 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:98c2e747-3338-1e27-a05c-ccae8bccb92e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C94A:6F3CF:94FBF35:D218DD6:6A51052D |
| html-safe-nonce | 3d444542a9967c0bdb1625fa3d7a72ad386228795e32928e50aff6302b22cdd8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTRBOjZGM0NGOjk0RkJGMzU6RDIxOERENjo2QTUxMDUyRCIsInZpc2l0b3JfaWQiOiIxNzI3NDExMTk5NDE3NTgyODkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e43b05c08ec865c178aa0a273a26b154464325dc338dddacdc0dbbc4618d8d07 |
| hovercard-subject-tag | issue:1116829975 |
| 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/22338/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4e06a1bc9a51b1f501683d9d866a7556501122eaffef7956457d663c3cfe8aa0/matplotlib/matplotlib/issues/22338 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4e06a1bc9a51b1f501683d9d866a7556501122eaffef7956457d663c3cfe8aa0/matplotlib/matplotlib/issues/22338 |
| og:image:alt | Bug summary We can now use a (x,y) argument for plt.legend(loc=(x,y)), but using the tuple as a value for rcParams['legend.loc'] fails. Code for reproduction import matplotlib.pyplot as plt import ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cphlewis |
| hostname | github.com |
| expected-hostname | github.com |
| None | 38906a4da4e3e9fd88dfeacee232f5932c0c5f7495de3b4efc53ddfac7173d12 |
| 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 | 90441ea9b98e7491aa6ebcd135fccce4e2396f48 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width