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 overflows outside its axes into adjacent
axes or outside the figure entirely, making the plot look broken.
Example: A 2-column subplot figure where a long annotation in the
left axes spills into the right axes area.
Proposed solution
Add an option for wrap=True to respect the axes boundary when text
is placed inside an axes, so annotations stay visually contained
within their axes.
This could be implemented by checking whether the text object belongs
to an axes (self.axes is not None) in the _get_wrap_line_width()
method of text.py, and using the axes boundary instead of the figure
boundary when calculating the available wrap width.
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 overflows outside its axes into adjacent
axes or outside the figure entirely, making the plot look broken.
Example: A 2-column subplot figure where a long annotation in the
left axes spills into the right axes area.
Proposed solution
Add an option for wrap=True to respect the axes boundary when text
is placed inside an axes, so annotations stay visually contained
within their axes.
This could be implemented by checking whether the text object belongs
to an axes (self.axes is not None) in the _get_wrap_line_width()
method of text.py, and using the axes boundary instead of the figure
boundary when calculating the available wrap width.