Title: [ENH]: Optional axes-aware text wrapping for wrap=True · Issue #31655 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: Optional axes-aware text wrapping for wrap=True · Issue #31655 · matplotlib/matplotlib
X Title: [ENH]: Optional axes-aware text wrapping for wrap=True · Issue #31655 · matplotlib/matplotlib
Description: Problem When creating multi-axes figures with subplots (e.g. dashboards, reports, side-by-side comparisons), using ax.text() with wrap=True causes text to wrap based on the figure boundary instead of the axes boundary. This means text ov...
Open Graph Description: Problem When creating multi-axes figures with subplots (e.g. dashboards, reports, side-by-side comparisons), using ax.text() with wrap=True causes text to wrap based on the figure boundary instead ...
X Description: Problem When creating multi-axes figures with subplots (e.g. dashboards, reports, side-by-side comparisons), using ax.text() with wrap=True causes text to wrap based on the figure boundary instead ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31655
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: Optional axes-aware text wrapping for wrap=True","articleBody":"### Problem\n\nWhen creating multi-axes figures with subplots (e.g. dashboards, \nreports, side-by-side comparisons), using ax.text() with wrap=True \ncauses text to wrap based on the figure boundary instead of the axes \nboundary. This means text overflows outside its axes into adjacent \naxes or outside the figure entirely, making the plot look broken.\n\n**Example:** A 2-column subplot figure where a long annotation in the \nleft axes spills into the right axes area.\n\n### Proposed solution\n\nAdd an option for wrap=True to respect the axes boundary when text \nis placed inside an axes, so annotations stay visually contained \nwithin their axes.\n\nThis could be implemented by checking whether the text object belongs \nto an axes (self.axes is not None) in the _get_wrap_line_width() \nmethod of text.py, and using the axes boundary instead of the figure \nboundary when calculating the available wrap width.","author":{"url":"https://github.com/codegnan-dm","@type":"Person","name":"codegnan-dm"},"datePublished":"2026-05-11T04:17:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/31655/matplotlib/issues/31655"}
| 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:0deb20a8-d791-c6d4-2be0-53090caf6082 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BE8:1BE578:CC586A:111C6F8:6A52C655 |
| html-safe-nonce | 7ab2e0d537a306cd8f55d4cb918e243f7e66c13c9886a40a6e09d56a27516cac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkU4OjFCRTU3ODpDQzU4NkE6MTExQzZGODo2QTUyQzY1NSIsInZpc2l0b3JfaWQiOiI4NjkzOTYwMTI3NjIyMDcxODkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 03d16e52fc9d38b916502dea52c3cf5c042b974d92b04e29615f47d9562225fb |
| hovercard-subject-tag | issue:4418031285 |
| 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/31655/issue_layout |
| twitter:image | https://opengraph.githubassets.com/97644dd94db16e11c16de0c75a17cc0f97cb963b662ddaefae0573aac5d1d431/matplotlib/matplotlib/issues/31655 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/97644dd94db16e11c16de0c75a17cc0f97cb963b662ddaefae0573aac5d1d431/matplotlib/matplotlib/issues/31655 |
| og:image:alt | Problem When creating multi-axes figures with subplots (e.g. dashboards, reports, side-by-side comparisons), using ax.text() with wrap=True causes text to wrap based on the figure boundary instead ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | codegnan-dm |
| 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