Title: [Bug]: Thick line just outside the figure edge disappears although part of it is inside the axes · Issue #32642 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Thick line just outside the figure edge disappears although part of it is inside the axes · Issue #32642 · matplotlib/matplotlib
X Title: [Bug]: Thick line just outside the figure edge disappears although part of it is inside the axes · Issue #32642 · matplotlib/matplotlib
Description: Bug summary A thick unfilled line whose centre lies just outside the figure is not drawn at all with the Agg backend, even though almost half of its width falls inside the axes. If the same axes have some empty space around them in the f...
Open Graph Description: Bug summary A thick unfilled line whose centre lies just outside the figure is not drawn at all with the Agg backend, even though almost half of its width falls inside the axes. If the same axes ha...
X Description: Bug summary A thick unfilled line whose centre lies just outside the figure is not drawn at all with the Agg backend, even though almost half of its width falls inside the axes. If the same axes ha...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/32642
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Thick line just outside the figure edge disappears although part of it is inside the axes","articleBody":"### Bug summary\n\nA thick unfilled line whose centre lies just outside the figure is not drawn at all with the Agg backend, even though almost half of its width falls inside the axes. If the same axes have some empty space around them in the figure, the visible half of the line is drawn as expected.\n\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n\ndef draw(margin):\n # The same 400x300 px axes, placed in a figure with `margin` px of space around it.\n W, H = 400 + 2 * margin, 300 + 2 * margin\n fig = plt.figure(figsize=(W / 100, H / 100), dpi=100)\n ax = fig.add_axes([margin / W, margin / H, 400 / W, 300 / H])\n ax.set_axis_off()\n ax.set(xlim=(0, 1), ylim=(0, 1))\n # A thick line slightly below the bottom of the axes; its upper half lies inside the axes.\n ax.plot([0.1, 0.9], [-0.004, -0.004], lw=30, color=\"k\")\n fig.canvas.draw()\n img = np.asarray(fig.canvas.buffer_rgba())[margin:margin + 300, margin:margin + 400]\n return (img[..., :3].min(-1) \u003c 128).sum()\n\n\nprint(\"dark pixels inside the axes, no margin: \", draw(0))\nprint(\"dark pixels inside the axes, 40 px margin:\", draw(40))\n```\n\n### Actual outcome\n\n```\ndark pixels inside the axes, no margin: 0\ndark pixels inside the axes, 40 px margin: 7240\n```\n\nWith no margin, the line is missing completely.\n\n\u003cimg width=\"920\" height=\"380\" alt=\"before_after\" src=\"https://github.com/user-attachments/assets/af611d5e-655b-42fa-971e-c4587987b53f\" />\n\n### Expected outcome\n\nThe same image in both cases: the upper half of the line visible along the bottom of the axes.\n\n\n### Additional information\n\nBefore stroking, Agg clips unfilled paths to the canvas grown by 1 px (`PathClipper`, rectangle `(-1, -1, width + 1, height + 1)` in `src/path_converters.h`). The rectangle does not account for the line width, so a line whose centre is more than 1 px outside the canvas is removed, even when its stroke reaches into the image.\n\nGrowing the rectangle by half the line width would cover round and butt caps and joins. Projecting caps and miter joins reach further, and the miter case relates to #9830. I'm not sure which approach you'd prefer.\n\nThe same output with the released 3.10.8.\n\n### Operating system\n\nLinux (Ubuntu 22.04)\n\n### Matplotlib Version\n\n3.12.0.dev943+gc21a3923e\n\n### Matplotlib Backend\n\nagg\n\n### Python version\n\n3.14.10\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\ngit checkout","author":{"url":"https://github.com/yqtian-se","@type":"Person","name":"yqtian-se"},"datePublished":"2026-11-22T12:37:01Z","url":"https://github.com/matplotlib/matplotlib/issues/32642"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:785127fe-0309-1d2e-56c6-6a504bff0e97 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C15E:23E430:10540B9:15A2EC7:6B064EEA |
| html-safe-nonce | c6f46f671df321d4d154f5a986ae1434dcab802385efe8bdeb8c8fe934d11d7f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTVFOjIzRTQzMDoxMDU0MEI5OjE1QTJFQzc6NkIwNjRFRUEiLCJ2aXNpdG9yX2lkIjoiNjQ4ODAwNzU0MzY0NTE2MzI0MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bc26388b37b11408159735524b79d0da85a5ec7ef469a96c83a4ce9cc2c48707 |
| hovercard-subject-tag | issue:6542458893 |
| 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/32642/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0bed3d033280f07e9d428e073ea2e0872794ff41831ac8858df6fb906cddfec8/matplotlib/matplotlib/issues/32642 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0bed3d033280f07e9d428e073ea2e0872794ff41831ac8858df6fb906cddfec8/matplotlib/matplotlib/issues/32642 |
| og:image:alt | Bug summary A thick unfilled line whose centre lies just outside the figure is not drawn at all with the Agg backend, even though almost half of its width falls inside the axes. If the same axes ha... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yqtian-se |
| hostname | github.com |
| expected-hostname | github.com |
| None | 772b6997ca4daa0428dd49a25d76052e765555ae560fe9c88517eb828bbd861e |
| 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 | f1f9a08f7c769a37f1dfc18ad43d463c222a7eea |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width