MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _get_wrap_line_width

Method _get_wrap_line_width

lib/matplotlib/text.py:729–753  ·  view source on GitHub ↗

Return the maximum line width for wrapping text based on the current orientation.

(self)

Source from the content-addressed store, hash-verified

727 self._wrap = wrap
728
729 def _get_wrap_line_width(self):
730 """
731 Return the maximum line width for wrapping text based on the current
732 orientation.
733 """
734 x0, y0 = self.get_transform().transform(self.get_position())
735 figure_box = self.get_figure().get_window_extent()
736
737 # Calculate available width based on text alignment
738 alignment = self.get_horizontalalignment()
739 self.set_rotation_mode('anchor')
740 angle = self.get_rotation()
741
742 left = self._get_dist_to_box(angle, x0, y0, figure_box)
743 right = self._get_dist_to_box(
744 (180 + angle) % 360, x0, y0, figure_box)
745
746 if alignment == 'left':
747 line_width = left
748 elif alignment == 'right':
749 line_width = right
750 else:
751 line_width = 2 * min(left, right)
752
753 return line_width
754
755 def _get_dist_to_box(self, rotation, x0, y0, figure_box):
756 """

Callers 1

_get_wrapped_textMethod · 0.95

Calls 9

get_positionMethod · 0.95
set_rotation_modeMethod · 0.95
get_rotationMethod · 0.95
_get_dist_to_boxMethod · 0.95
transformMethod · 0.45
get_transformMethod · 0.45
get_window_extentMethod · 0.45
get_figureMethod · 0.45

Tested by

no test coverage detected