{"action":"created","issue":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/10458","repository_url":"https://api.github.com/repos/matplotlib/matplotlib","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/10458/labels{/name}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/10458/comments","events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/10458/events","html_url":"https://github.com/matplotlib/matplotlib/issues/10458","id":297149751,"number":10458,"title":"Draggable legend changes position when saving as PDF","user":{"login":"AgilentGCMS","id":3866945,"avatar_url":"https://avatars2.githubusercontent.com/u/3866945?v=4","gravatar_id":"","url":"https://api.github.com/users/AgilentGCMS","html_url":"https://github.com/AgilentGCMS","followers_url":"https://api.github.com/users/AgilentGCMS/followers","following_url":"https://api.github.com/users/AgilentGCMS/following{/other_user}","gists_url":"https://api.github.com/users/AgilentGCMS/gists{/gist_id}","starred_url":"https://api.github.com/users/AgilentGCMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgilentGCMS/subscriptions","organizations_url":"https://api.github.com/users/AgilentGCMS/orgs","repos_url":"https://api.github.com/users/AgilentGCMS/repos","events_url":"https://api.github.com/users/AgilentGCMS/events{/privacy}","received_events_url":"https://api.github.com/users/AgilentGCMS/received_events","type":"User","site_admin":false},"labels":[{"id":174402448,"url":"https://api.github.com/repos/matplotlib/matplotlib/labels/Difficulty:%20Medium","name":"Difficulty: Medium","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/32","html_url":"https://github.com/matplotlib/matplotlib/milestone/32","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/32/labels","id":3106572,"number":32,"title":"v2.2.1","description":"First bugfix release for 2.2.x series.\r\n\r\non-merge: backport to v2.2.x","creator":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars3.githubusercontent.com/u/199813?v=4","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":3,"state":"open","created_at":"2018-02-12T03:21:43Z","updated_at":"2018-02-14T22:17:06Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2018-02-14T16:01:29Z","updated_at":"2018-02-14T22:49:36Z","closed_at":null,"author_association":"NONE","body":"<!--To help us understand and resolve your issue, please fill out the form to the best of your ability.-->\r\n<!--You can feel free to delete the sections that do not apply.-->\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nIf I add a draggable legend to a plot, then move it to a desired position by dragging it, then save the plot to a PDF by using savefig, the legend position on the PDF is not the same as the legend position I dragged it to on the screen.\r\n\r\n**Code for reproduction**\r\n\r\n<!--A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required-->\r\n\r\n```python\r\nfrom matplotlib import pyplot as plt\r\nimport numpy as np\r\n\r\nx = np.linspace(-2.*np.pi, 2.*np.pi, 1000)\r\ny = np.sin(x)\r\nplt.plot(x, y, '-', lw=2, label='Sine curve')\r\nleg = plt.legend(loc='best', fontsize=20)\r\nleg.draggable(True)\r\nplt.show()\r\n```\r\nAfter running this code, drag the legend manually to the lower left of the plot, then issue the command\r\n```python\r\nplt.savefig('sine_curve.pdf')\r\n```\r\n\r\n\r\n**Actual outcome**\r\n\r\nOn the screen, after dragging the legend the plot looks like plot_on_screen.png. However, the saved PDF looks like sine_curve.pdf. Notice how the legend is obviously at a different location than where I placed it by dragging.\r\n![plot_on_screen](https://user-images.githubusercontent.com/3866945/36213894-234d8ea0-1165-11e8-8071-2ee28faaae8c.png)\r\n[sine_curve.pdf](https://github.com/matplotlib/matplotlib/files/1724670/sine_curve.pdf)\r\n\r\n**Expected outcome**\r\n\r\nThe legend should stay in the same place in the PDF as on the screen. This used to be the case with matplotlib 1.5.3.\r\n\r\n**Matplotlib version**\r\n<!--Please specify your platform and versions of the relevant libraries you are using:-->\r\n  * Operating system: Linux x64\r\n  * Matplotlib version:  2.1.2\r\n  * Matplotlib backend: Qt4Agg\r\n  * Python version: 2.7.6\r\n  * Jupyter version (if applicable): N/A\r\n  * Other libraries: \r\n\r\nI installed matplotlib from source.\r\n"},"comment":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/comments/365771184","html_url":"https://github.com/matplotlib/matplotlib/issues/10458#issuecomment-365771184","issue_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/10458","id":365771184,"user":{"login":"afvincent","id":17270724,"avatar_url":"https://avatars1.githubusercontent.com/u/17270724?v=4","gravatar_id":"","url":"https://api.github.com/users/afvincent","html_url":"https://github.com/afvincent","followers_url":"https://api.github.com/users/afvincent/followers","following_url":"https://api.github.com/users/afvincent/following{/other_user}","gists_url":"https://api.github.com/users/afvincent/gists{/gist_id}","starred_url":"https://api.github.com/users/afvincent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afvincent/subscriptions","organizations_url":"https://api.github.com/users/afvincent/orgs","repos_url":"https://api.github.com/users/afvincent/repos","events_url":"https://api.github.com/users/afvincent/events{/privacy}","received_events_url":"https://api.github.com/users/afvincent/received_events","type":"User","site_admin":false},"created_at":"2018-02-14T22:49:36Z","updated_at":"2018-02-14T22:49:36Z","author_association":"CONTRIBUTOR","body":"FWIW, here is a manual testing script that shows the issue between the DPI value used for the display, and the DPI value used when saving the figure. \r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\nx = np.linspace(-2.*np.pi, 2.*np.pi, 1000)\r\ny = np.sin(x)\r\n\r\nfig, ax = plt.subplots(dpi=100, num='test_draggable_legend')\r\nax.plot(x, y, '-', lw=2, label='Sine curve')\r\nax.set_title(\"Display @ {} dpi\".format(fig.get_dpi()))\r\n\r\nleg = ax.legend(loc='best', fontsize=20)\r\nleg.draggable(True)\r\n\r\nplt.show()  # then move a bit the legend and close the figure\r\n\r\nfor ext, dpi in [('.png', 72), ('.png', 100), ('.png', 144), ('.pdf', None)]:\r\n    suffix = '_figsave_{}_dpi'.format(dpi if dpi is not None else 'None')\r\n    fig.savefig(fig.get_label() + suffix + ext, dpi=dpi)\r\n```\r\nproduces\r\n  - figsave @ 72 dpi (not OK with the display): ![test_draggable_legend_figsave_72_dpi](https://user-images.githubusercontent.com/17270724/36232208-b9bc7cfe-1195-11e8-8395-7122976127c7.png)\r\n  - figsave @ 100 dpi (OK with the display): ![test_draggable_legend_figsave_100_dpi](https://user-images.githubusercontent.com/17270724/36232213-be57368c-1195-11e8-998b-96f52298d042.png)\r\n  -  figsave @ 144 dpi (not OK with the display): <img width=\"461\" alt=\"test_draggable_legend_figsave_144_dpi\" src=\"https://user-images.githubusercontent.com/17270724/36232217-c1633a74-1195-11e8-8580-72a6e6ee8b62.png\">\r\n\r\nNB: I am going to edit the thread title as the issue does not seem specific to PDF.\r\n"}}
{"actor":{"display_login":"afvincent"}}