Title: Reactivating `pyplot.subplot` throws warning. · Issue #12513 · matplotlib/matplotlib · GitHub
Open Graph Title: Reactivating `pyplot.subplot` throws warning. · Issue #12513 · matplotlib/matplotlib
X Title: Reactivating `pyplot.subplot` throws warning. · Issue #12513 · matplotlib/matplotlib
Description: Bug report Bug summary Running plt.subplot after the respective subplot has already been created shows a warning. This behaviour is expected for fig.add_subplot. However in pyplot this is to my knowledge the recommended way to activate a...
Open Graph Description: Bug report Bug summary Running plt.subplot after the respective subplot has already been created shows a warning. This behaviour is expected for fig.add_subplot. However in pyplot this is to my kno...
X Description: Bug report Bug summary Running plt.subplot after the respective subplot has already been created shows a warning. This behaviour is expected for fig.add_subplot. However in pyplot this is to my kno...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/12513
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Reactivating `pyplot.subplot` throws warning.","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nRunning `plt.subplot` after the respective subplot has already been created shows a warning. This behaviour is expected for `fig.add_subplot`. However in pyplot this is to my knowledge the recommended way to activate a subplot, as seen from [the tutorial](https://matplotlib.org/tutorials/introductory/pyplot.html#working-with-multiple-figures-and-axes).\r\n\r\n**Code for reproduction**\r\n\r\nThe following is the code from the second code box in the [Working with multiple figures and axes](https://matplotlib.org/tutorials/introductory/pyplot.html#working-with-multiple-figures-and-axes) section of the basic pyplot guide.\r\n\r\n```\r\nimport matplotlib.pyplot as plt\r\nplt.figure(1) # the first figure\r\nplt.subplot(211) # the first subplot in the first figure\r\nplt.plot([1, 2, 3])\r\nplt.subplot(212) # the second subplot in the first figure\r\nplt.plot([4, 5, 6])\r\n\r\n\r\nplt.figure(2) # a second figure\r\nplt.plot([4, 5, 6]) # creates a subplot(111) by default\r\n\r\nplt.figure(1) # figure 1 current; subplot(212) still current\r\nplt.subplot(211) # make subplot(211) in figure1 current\r\nplt.title('Easy as 1, 2, 3') # subplot 211 title\r\n```\r\n\r\n**Actual outcome**\r\n\r\nWhen being run it produces a warning.\r\n\r\n\u003e MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.\r\n\r\n\r\n**Expected outcome**\r\n\r\nNo warning. Using `pyplot.subplot(211)` should just activate the subplot, as described in the tutorial. \r\n\r\nAlternatively, there needs to be another way to activate a subplot in pyplot (without having stored any handle to it previously).\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n\r\n * Matplotlib version: 2.2.2, 3.0.0 (possibly others)\r\n\r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\n","author":{"url":"https://github.com/ImportanceOfBeingErnest","@type":"Person","name":"ImportanceOfBeingErnest"},"datePublished":"2018-10-13T03:10:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":21},"url":"https://github.com/12513/matplotlib/issues/12513"}
| 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:6ddb0037-724c-4eee-5291-6b572e4a13a0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A92:28D644:733AFE:9B33BC:6A526D51 |
| html-safe-nonce | 6c430c5c291c472ea16c239d5d0a3d50d581dbd8ff1d4861af93a91eb5c1fecc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTkyOjI4RDY0NDo3MzNBRkU6OUIzM0JDOjZBNTI2RDUxIiwidmlzaXRvcl9pZCI6IjI3NjYzMzkxMDA4NDgwNTc2ODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9bf040ab654f53be26a46467bdc18c187bc20e703ee786cd678fafb88ea4397e |
| hovercard-subject-tag | issue:369761210 |
| 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/12513/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f6fe8e758a6e848b2647cca413fce2b3468d196e30f49f28bea7cfb90a769f1c/matplotlib/matplotlib/issues/12513 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f6fe8e758a6e848b2647cca413fce2b3468d196e30f49f28bea7cfb90a769f1c/matplotlib/matplotlib/issues/12513 |
| og:image:alt | Bug report Bug summary Running plt.subplot after the respective subplot has already been created shows a warning. This behaviour is expected for fig.add_subplot. However in pyplot this is to my kno... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ImportanceOfBeingErnest |
| 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