Title: Qt4Agg backend changes figure size · Issue #9913 · matplotlib/matplotlib · GitHub
Open Graph Title: Qt4Agg backend changes figure size · Issue #9913 · matplotlib/matplotlib
X Title: Qt4Agg backend changes figure size · Issue #9913 · matplotlib/matplotlib
Description: Edit: Note that this issue is also still present with Qt5Agg and matplotlib 3.0.1 Showing a figure with Qt4Agg backend changes the figure size. This is observed with Windows 8.1, python 2.7, matplotlib 2.1. import matplotlib matplotlib.u...
Open Graph Description: Edit: Note that this issue is also still present with Qt5Agg and matplotlib 3.0.1 Showing a figure with Qt4Agg backend changes the figure size. This is observed with Windows 8.1, python 2.7, matplo...
X Description: Edit: Note that this issue is also still present with Qt5Agg and matplotlib 3.0.1 Showing a figure with Qt4Agg backend changes the figure size. This is observed with Windows 8.1, python 2.7, matplo...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/9913
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Qt4Agg backend changes figure size","articleBody":"Edit: Note that this issue is also still present with Qt5Agg and matplotlib 3.0.1\r\n\r\nShowing a figure with Qt4Agg backend changes the figure size. This is observed with Windows 8.1, python 2.7, matplotlib 2.1.\r\n\r\n```\r\nimport matplotlib\r\nmatplotlib.use(\"Qt4Agg\")\r\nimport matplotlib.pyplot as plt\r\n\r\nfig, ax = plt.subplots()\r\nax.plot([1,2,4])\r\n\r\ndef update(evt):\r\n print(fig.get_size_inches())\r\n \r\ncid = fig.canvas.mpl_connect(\"key_press_event\", update)\r\n\r\nprint(fig.get_size_inches())\r\nplt.show()\r\n```\r\nThe original figure is `[ 6.4 4.8]`. After the figure is drawn (and in this case you press a key), it is only `[ 6.4 4.78]`. \r\nOne could argue that this is only a small amount, but saving the figure from within the event loop now gives a different figure size of the saved figure. To make this more obvious, consider the following code which saves a new image after each press of space.\r\n\r\n```\r\nimport matplotlib\r\nmatplotlib.use(\"Qt4Agg\")\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\nclass NextPlotter(object):\r\n def __init__(self, fig, func, n):\r\n self.__dict__.update(locals())\r\n self.i = 0\r\n self.cid = self.fig.canvas.mpl_connect(\"key_press_event\", self.adv)\r\n \r\n def adv(self, evt):\r\n if evt.key == \" \" and self.i \u003c self.n:\r\n self.func(self.i)\r\n self.i+=1\r\n elif self.i \u003e= self.n:\r\n plt.close(\"all\")\r\n\r\n# Create data\r\npos = range(8)\r\nscatterdata = np.random.normal(0, 5, size=(50,len(pos)))\r\n\r\n#Create plot\r\nfig, ax = plt.subplots()\r\nax.axis([-10,10,-10,10])\r\nscatter = ax.scatter([], [], c=\"crimson\", s=60)\r\n\r\n# define updating function\r\ndef update(i):\r\n print(\"++ update \" + str(i))\r\n scatter.set_offsets(np.c_[pos,scatterdata[i,:]])\r\n fig.canvas.draw()\r\n print(fig.get_size_inches())\r\n plt.savefig(\"plot_{i}.png\".format(i=i))\r\n print(fig.get_size_inches())\r\n\r\n# instantiate NextPlotter; press \u003cspace\u003e to advance to the next image \r\nc = NextPlotter(fig, update, len(scatterdata))\r\n\r\nplt.show()\r\n```\r\nresulting in \r\n\r\n\r\nIs this a problem of PyQt4? Can anyone reproduce this outside of Windows 8? ","author":{"url":"https://github.com/ImportanceOfBeingErnest","@type":"Person","name":"ImportanceOfBeingErnest"},"datePublished":"2017-12-02T15:53:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":20},"url":"https://github.com/9913/matplotlib/issues/9913"}
| 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:401a7374-1ede-f272-4947-40479daf202e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9E20:33B84F:4ADCB:65DC8:6A53D336 |
| html-safe-nonce | 62918e5bd0c723dade0e3ae20c0cacb30f32a733dfc81a216dfc3ba2789e94af |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTIwOjMzQjg0Rjo0QURDQjo2NURDODo2QTUzRDMzNiIsInZpc2l0b3JfaWQiOiI0MTY5NDI3OTk3ODgyMDQ1MjM4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | cd61d77b13f58863957c6f36eb942e6b33145c0ab3ed60342d88bfcb8ff8dda5 |
| hovercard-subject-tag | issue:278693871 |
| 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/9913/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7d15f71a00b97ff4f699b7dd5a8926c52686ffb99d7058f173693f3bb0d75505/matplotlib/matplotlib/issues/9913 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7d15f71a00b97ff4f699b7dd5a8926c52686ffb99d7058f173693f3bb0d75505/matplotlib/matplotlib/issues/9913 |
| og:image:alt | Edit: Note that this issue is also still present with Qt5Agg and matplotlib 3.0.1 Showing a figure with Qt4Agg backend changes the figure size. This is observed with Windows 8.1, python 2.7, matplo... |
| 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 | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width