Title: [Bug]: savefig() breaks FancyArrowPatch position on saved PNG when using custom DPI · Issue #31536 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: savefig() breaks FancyArrowPatch position on saved PNG when using custom DPI · Issue #31536 · matplotlib/matplotlib
X Title: [Bug]: savefig() breaks FancyArrowPatch position on saved PNG when using custom DPI · Issue #31536 · matplotlib/matplotlib
Description: Bug summary Heyho, I encountered an error with patches (FancyArrowPatch). When i draw FancyArrowPatches into a figure and save the figures with savefig(), the patches shift around to different positions depending on my set dpi=parameter ...
Open Graph Description: Bug summary Heyho, I encountered an error with patches (FancyArrowPatch). When i draw FancyArrowPatches into a figure and save the figures with savefig(), the patches shift around to different posi...
X Description: Bug summary Heyho, I encountered an error with patches (FancyArrowPatch). When i draw FancyArrowPatches into a figure and save the figures with savefig(), the patches shift around to different posi...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31536
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: savefig() breaks FancyArrowPatch position on saved PNG when using custom DPI","articleBody":"### Bug summary\n\nHeyho,\n\nI encountered an error with patches (FancyArrowPatch).\nWhen i draw FancyArrowPatches into a figure and save the figures with savefig(), the patches shift around to different positions depending on my set `dpi=`parameter as shown by the following screenshots, produced by code underneath.\n\n\n### Code for reproduction\n\n```Python\nimport os\nfrom os.path import dirname\n\nimport copy\n\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as patches\n\n\n\nos.chdir(dirname(__file__))\nprint(f\"Changed WD to PyFile-root \\\"{os.getcwd()}\\\"\")\n\n\nColor1 = \"#1776D4\"\nColor2 = \"#E27A12\"\n\nfig, axL = plt.subplots(nrows=1, ncols=1)\naxR = axL.twinx()\n\nplt.show(block=False)\n\n\narrowUpBG = patches.FancyArrowPatch(\n posA=(0.500, 0.535), # Startpoint Arrow (0..1)\n posB=(0.560, 0.560), # Endpoint Base (0..1)\n transform=fig.transFigure, # Coordinate system of figure\n arrowstyle='fancy',\n color=Color1,\n linewidth=10,\n mutation_scale=30\n)\n\n# NOTE: Copies have to be made before first draw! Otherwise figure gets cloned too!\narrowUpFG = copy.deepcopy(arrowUpBG)\narrowUpFG.set_color(Color2)\narrowUpFG.set_linewidth(1)\n\narrowDownBG = copy.deepcopy(arrowUpBG)\narrowDownFG = copy.deepcopy(arrowUpFG)\narrowDownBG.set_positions(posA=(0.590, 0.745), # Startpoint Arrow (0..1)\n posB=(0.535, 0.690), # Endpoint Base (0..1)\n )\narrowDownFG.set_positions(posA=(0.590, 0.745),\n posB=(0.535, 0.690),\n )\n\n# NOTE: Draw is here (together, copies have to be made beforehand, as otherwise savefig gets cloned too!)\nfig.add_artist(arrowUpBG)\nfig.add_artist(arrowUpFG)\n\nfig.add_artist(arrowDownBG)\nfig.add_artist(arrowDownFG)\n\n\n\nfig.savefig(\"./FancyIssue - SVG.svg\")\nfig.savefig(\"./FancyIssue - Std dpi.png\")\nfig.savefig(\"./FancyIssue - 200 dpi.png\", dpi=200)\nfig.savefig(\"./FancyIssue - 300 dpi.png\", dpi=300)\nfig.savefig(\"./FancyIssue - 600 dpi.png\", dpi=600)\n\nprint(\"EOS\")\n```\n\n### Actual outcome\n\n| DPI | Standard | 200 | 300 | 600 | SVG (in Firefox) |\n|-----|-----------|------|-----|------|------------------|\n| Imgs |\u003cimg width=\"640\" height=\"480\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/15f133ed-03a3-4a63-a627-415cb5e36a0a\" /\u003e | \u003cimg width=\"1280\" height=\"960\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/113f024c-cb45-46bb-a86d-dd7664ad42d1\" /\u003e | \u003cimg width=\"1920\" height=\"1440\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/01440e27-35a4-424a-81df-725333775812\" /\u003e| \u003cimg width=\"3840\" height=\"2880\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/87a2a221-0c2e-45b8-a4bd-cc334d9cbbd1\" /\u003e | \u003cimg width=\"552\" height=\"435\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/e7142f64-24ed-48a1-869f-84c4aa431379\" /\u003e |\n\n### Expected outcome\n\nPatches stay in relative position to the figure size.\nNote: The patches are drawn correctly in the preview (plt.show()).\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nWindows 11 (24H2)\n\n### Matplotlib Version\n\n 3.10.8\n\n### Matplotlib Backend\n\n tkagg\n\n### Python version\n\n3.14.3\n\n### Jupyter version\n\nN/A\n\n### Installation\n\npip\n\n\n\n\n\nBest regards,\nDeph","author":{"url":"https://github.com/Dephrilibrium","@type":"Person","name":"Dephrilibrium"},"datePublished":"2026-04-20T15:26:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/31536/matplotlib/issues/31536"}
| 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:359568dc-a0c3-01a0-df12-bec3420f71ef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A3C2:355EFE:78C965:A3B4F9:6A5287EF |
| html-safe-nonce | abe87308a70339a6042d00f2157e17b6ad24d4139c8adddb5d05c6cf1dc49748 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0MyOjM1NUVGRTo3OEM5NjU6QTNCNEY5OjZBNTI4N0VGIiwidmlzaXRvcl9pZCI6IjQzMTAxNjkyODI5ODgzNzgwOTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b02cf22e3334122647f9e77737408710e03ce63b1ad34ea85c73043f307e8b68 |
| hovercard-subject-tag | issue:4296792000 |
| 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/31536/issue_layout |
| twitter:image | https://opengraph.githubassets.com/66a1adb0eb2aadf064057231cf4220cfda8089703e2de5d973ea6611aa4b8174/matplotlib/matplotlib/issues/31536 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/66a1adb0eb2aadf064057231cf4220cfda8089703e2de5d973ea6611aa4b8174/matplotlib/matplotlib/issues/31536 |
| og:image:alt | Bug summary Heyho, I encountered an error with patches (FancyArrowPatch). When i draw FancyArrowPatches into a figure and save the figures with savefig(), the patches shift around to different posi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Dephrilibrium |
| 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