Title: bbox images do not get placed properly when figure is saved to png or pdf · Issue #3918 · matplotlib/matplotlib · GitHub
Open Graph Title: bbox images do not get placed properly when figure is saved to png or pdf · Issue #3918 · matplotlib/matplotlib
X Title: bbox images do not get placed properly when figure is saved to png or pdf · Issue #3918 · matplotlib/matplotlib
Description: When I create a figure using bbox images, everything looks fine, but when I save the figure, the images move. Here is an example import matplotlib.pyplot as plt import numpy as np from matplotlib.image import BboxImage from matplotlib.tr...
Open Graph Description: When I create a figure using bbox images, everything looks fine, but when I save the figure, the images move. Here is an example import matplotlib.pyplot as plt import numpy as np from matplotlib.i...
X Description: When I create a figure using bbox images, everything looks fine, but when I save the figure, the images move. Here is an example import matplotlib.pyplot as plt import numpy as np from matplotlib.i...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/3918
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bbox images do not get placed properly when figure is saved to png or pdf","articleBody":"When I create a figure using bbox images, everything looks fine, but when I save the figure, the images move. Here is an example\n\n```\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom matplotlib.image import BboxImage\nfrom matplotlib.transforms import Bbox, TransformedBbox\n\n#Generate the image\nim = np.random.rand(10, 10) * 255.0\n\n#Set up figure\nfig = plt.figure()\nax = fig.add_axes([0.1,0.1,0.8,0.8])\nax.set_xlim(-2,24)\nax.set_ylim(0,10)\n\n#Create image that transforms automatically\nbbox1 = Bbox.from_extents([0,0,10,10])\ntrans_bbox1 = TransformedBbox(bbox1, ax.transData)\nbbox_image1 = BboxImage(trans_bbox1)\nbbox_image1.set_data(im)\nax.add_image(bbox_image1)\n\n#Create image that does not transform\nbbox2 = Bbox.from_extents([12,0,22,10])\ntrans_bbox2 = bbox2.transformed(ax.transData)\nbbox_image2 = BboxImage(trans_bbox2)\nbbox_image2.set_data(im)\nax.add_image(bbox_image2)\n\n#Save the result\nfig.savefig('png_test.png')\nfig.savefig('pdf_test.pdf')\n```\n\nIf I take a screenshot of the figure window, it looks like this\n\nwhich is what I expect. However, when I look at the 'png_test.png', the second image that did not use the `TransformedBbox` moves, as shown below\n\nIn the pdf, both images move, as shown below\n\n\nIn case it matters, I am using the Qt4Agg interactive backend with the Spyder IDE. My matplotlib version is 1.4.0.\n","author":{"url":"https://github.com/breedlun","@type":"Person","name":"breedlun"},"datePublished":"2014-12-13T05:29:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":20},"url":"https://github.com/3918/matplotlib/issues/3918"}
| 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:40a01308-906a-0df5-34dc-c12f36d72348 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E37A:1258BB:A7E4BD:E38941:6A53144A |
| html-safe-nonce | cc9284b4fd30e2132035903871e12e197ba87358c123b6ca7916e52ca6498025 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzdBOjEyNThCQjpBN0U0QkQ6RTM4OTQxOjZBNTMxNDRBIiwidmlzaXRvcl9pZCI6Ijc1NjA1MzcwNzg3NTQzODI5MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 65d0c5439dcc161ca5fad9ecaf385843286dd7e079c3a6e2015b0798d2c13a0b |
| hovercard-subject-tag | issue:51877402 |
| 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/3918/issue_layout |
| twitter:image | https://opengraph.githubassets.com/75e93fc9cff099bba7b52fce01ca4fdb07a36013416621ae6e0b15f7245e74d6/matplotlib/matplotlib/issues/3918 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/75e93fc9cff099bba7b52fce01ca4fdb07a36013416621ae6e0b15f7245e74d6/matplotlib/matplotlib/issues/3918 |
| og:image:alt | When I create a figure using bbox images, everything looks fine, but when I save the figure, the images move. Here is an example import matplotlib.pyplot as plt import numpy as np from matplotlib.i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | breedlun |
| 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