Title: [Bug]: Clip box property of ax.text(...) has no effect · Issue #30718 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Clip box property of ax.text(...) has no effect · Issue #30718 · matplotlib/matplotlib
X Title: [Bug]: Clip box property of ax.text(...) has no effect · Issue #30718 · matplotlib/matplotlib
Description: Bug summary Setting the clip_box property of text generated with ax.text(...) has no effect, regardless of whether it is set directly during generation with the clip_box parameter or afterwards with the setter function text.set_clip_box(...
Open Graph Description: Bug summary Setting the clip_box property of text generated with ax.text(...) has no effect, regardless of whether it is set directly during generation with the clip_box parameter or afterwards wit...
X Description: Bug summary Setting the clip_box property of text generated with ax.text(...) has no effect, regardless of whether it is set directly during generation with the clip_box parameter or afterwards wit...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30718
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Clip box property of ax.text(...) has no effect","articleBody":"### Bug summary\n\nSetting the `clip_box` property of text generated with `ax.text(...)` has no effect, regardless of whether it is set directly during generation with the `clip_box` parameter or afterwards with the setter function `text.set_clip_box(...)`.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\nfrom matplotlib.transforms import Bbox, TransformedBbox\n\n# Create data for the plot\nx = range(10)\ny = range(10)\n\n# Create the plot\nfig, ax = plt.subplots()\n\n# Create a bounding box\nbbox = Bbox([[5, 2], [7, 8]])\n# Transform the bounding box to the coordinate system of the data\ntbbox = TransformedBbox(bbox, ax.transData)\n\n# Draw the bounding box on the plot for better understanding\nrect = plt.Rectangle((bbox.xmin, bbox.ymin), bbox.width, bbox.height, fill=False, edgecolor='r', linewidth=2)\nax.add_patch(rect)\n\n# Plot a line and a text\nline, = ax.plot(x, y, color='blue')\ntext = ax.text(5, 5, \"Lorem ipsum dolor sit amet.\")\n\n# Apply the bounding box to the line and text\nline.set_clip_box(tbbox)\ntext.set_clip_box(tbbox)\n\n# Show the plot\nplt.show()\n```\n\n### Actual outcome\n\nWhile the line drawn with ax.plot(...) is correctly clipped, the text is not clipped:\n\u003cimg width=\"640\" height=\"480\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/2279fd06-7fde-4c99-8b5a-bf0e686a2c46\" />\n\n### Expected outcome\n\nThe text should be clipped in the same way as the line:\n\u003cimg width=\"640\" height=\"480\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/631e1eaa-9121-4058-8679-c17b9e1e3f7a\" />\n\n### Additional information\n\nThe same problem occurs if you use `text = ax.text(5, 5, \"Lorem ipsum dolor sit amet.\", clip_box=tbbox)` in line 22 instead of line 26.\n\n### Operating system\n\nWindows 11\n\n### Matplotlib Version\n\n3.10.7\n\n### Matplotlib Backend\n\nmodule://backend_interagg\n\n### Python version\n\n3.14.0\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/leofels","@type":"Person","name":"leofels"},"datePublished":"2025-11-02T18:52:02Z","url":"https://github.com/matplotlib/matplotlib/issues/30718"}
| 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:e132600b-969a-8eb5-ecdc-d2ba85aa905c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EDB2:E76E0:1193AC0:177667C:6B065CA3 |
| html-safe-nonce | f0693c6bf500748c9871fbe80648f3ec714e459a9346f497e2f51defd18403d9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREIyOkU3NkUwOjExOTNBQzA6MTc3NjY3Qzo2QjA2NUNBMyIsInZpc2l0b3JfaWQiOiIyMzg5NTQ1NDAzODQ3OTU3NjY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 09467b88cb32e8629b23823e30e819a1d042e33d2d944920ac2d08c5841709ea |
| hovercard-subject-tag | issue:3579832847 |
| 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/30718/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d974b5d26c492e3d6ac547e914ed15ca96e65a8704ee028dfebf1dd6ea12880/matplotlib/matplotlib/issues/30718 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d974b5d26c492e3d6ac547e914ed15ca96e65a8704ee028dfebf1dd6ea12880/matplotlib/matplotlib/issues/30718 |
| og:image:alt | Bug summary Setting the clip_box property of text generated with ax.text(...) has no effect, regardless of whether it is set directly during generation with the clip_box parameter or afterwards wit... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | leofels |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6324e6ac990fb6befbec840cc0e102a1071c339bfe8f9826bb12de2e3ba1d297 |
| 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 | 7f0aa75f4141d440c6110dc31af7ea7797abb6c4 |
| ui-target | full |
| 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