Title: Feature request - make it simpler to use full OO interface · Issue #1094 · matplotlib/matplotlib · GitHub
Open Graph Title: Feature request - make it simpler to use full OO interface · Issue #1094 · matplotlib/matplotlib
X Title: Feature request - make it simpler to use full OO interface · Issue #1094 · matplotlib/matplotlib
Description: I would like to start using the matplotlib OO interface more, as I would prefer to use this when interactive plotting is not needed. It it slightly faster, and behaves more intuitively in terms of reference counting (pyplot keeps a refer...
Open Graph Description: I would like to start using the matplotlib OO interface more, as I would prefer to use this when interactive plotting is not needed. It it slightly faster, and behaves more intuitively in terms of ...
X Description: I would like to start using the matplotlib OO interface more, as I would prefer to use this when interactive plotting is not needed. It it slightly faster, and behaves more intuitively in terms of ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/1094
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature request - make it simpler to use full OO interface","articleBody":"I would like to start using the matplotlib OO interface more, as I would prefer to use this when interactive plotting is not needed. It it slightly faster, and behaves more intuitively in terms of reference counting (pyplot keeps a reference to each figure, meaning that if figures are not closed by pyplot, memory goes out of control).\n\nThe reason I don't use it is because it's not easy to remember all the set-up of the canvas and figure:\n\n```\nfrom matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas\nfrom matplotlib.figure import Figure\n\nfig = Figure()\ncanvas = FigureCanvas(fig)\nax = fig.add_subplot(1, 1, 1)\nax.scatter(np.random.random(10), np.random.random(10))\nfig.savefig('test.png')\n```\n\nSo I was wondering whether it would be possible to make `Figure` more intelligent in terms of canvas? The 'ideal' API in my mind would be:\n\n```\nfrom matplotlib.figure import Figure\n\nfig = Figure()\nax = fig.add_subplot(1, 1, 1)\nax.scatter(np.random.random(10), np.random.random(10))\nfig.savefig('test.png')\n```\n\ni.e. I want the figure to just use the default backend (since this is set at the root level of matplotlib, _not_ pyplot). So I would expect the following to work:\n\n```\nimport matplotlib\nmatplotlib.use('Agg')\nfrom matplotlib.figure import Figure\n\nfig = Figure()\nax = fig.add_subplot(1, 1, 1)\nax.scatter(np.random.random(10), np.random.random(10))\nfig.savefig('test.png')\n```\n\nand to use the non-interactive Agg backend.\n\nIs this something that has been considered before?\n","author":{"url":"https://github.com/astrofrog","@type":"Person","name":"astrofrog"},"datePublished":"2012-08-16T13:31:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/1094/matplotlib/issues/1094"}
| 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:a3ad0530-ba66-967d-e11c-d09e8cb1792b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB7C:29ED71:8541F:B32C0:6A532B63 |
| html-safe-nonce | ae500c16fc7f8e9092adc0813e0582f09d51a088a63bba7584143cd06c5884f0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjdDOjI5RUQ3MTo4NTQxRjpCMzJDMDo2QTUzMkI2MyIsInZpc2l0b3JfaWQiOiIyNjg4ODAzNDM5MjMyODg3NjUxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 124cae8e371cc4e08f328539a3c125618cb40fe586bb4b066cb3f184aaf8fbdf |
| hovercard-subject-tag | issue:6264458 |
| 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/1094/issue_layout |
| twitter:image | https://opengraph.githubassets.com/24b7646b761916c273c5536ac5e18a0a33b326133f11b35279da6e1b855d6a3a/matplotlib/matplotlib/issues/1094 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/24b7646b761916c273c5536ac5e18a0a33b326133f11b35279da6e1b855d6a3a/matplotlib/matplotlib/issues/1094 |
| og:image:alt | I would like to start using the matplotlib OO interface more, as I would prefer to use this when interactive plotting is not needed. It it slightly faster, and behaves more intuitively in terms of ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | astrofrog |
| 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