|
10 | 10 |
|
11 | 11 | from ..utils import ( |
12 | 12 | ArtistGeometry, |
13 | | - JustifyBoundaries, |
14 | 13 | TextJustifier, |
15 | 14 | get_subplotspecs, |
16 | 15 | rel_position, |
@@ -354,7 +353,17 @@ def _move_artists(self, spaces: PlotSideSpaces): |
354 | 353 | plot_title_position = theme.getp("plot_title_position", "panel") |
355 | 354 | plot_caption_position = theme.getp("plot_caption_position", "panel") |
356 | 355 | plot_footer_position = theme.getp("plot_footer_position", "plot") |
357 | | - justify = PlotTextJustifier(spaces) |
| 356 | + justify = TextJustifier.from_boundaries( |
| 357 | + spaces.plot.figure, |
| 358 | + plot_left=spaces.l.plot_left, |
| 359 | + plot_right=spaces.r.plot_right, |
| 360 | + plot_bottom=spaces.b.plot_bottom, |
| 361 | + plot_top=spaces.t.plot_top, |
| 362 | + panel_left=spaces.l.panel_left, |
| 363 | + panel_right=spaces.r.panel_right, |
| 364 | + panel_bottom=spaces.b.panel_bottom, |
| 365 | + panel_top=spaces.t.panel_top, |
| 366 | + ) |
358 | 367 |
|
359 | 368 | if self.plot_tag: |
360 | 369 | set_plot_tag_position(self.plot_tag, spaces) |
@@ -407,7 +416,7 @@ def _move_artists(self, spaces: PlotSideSpaces): |
407 | 416 | self._strip_text_x_background_equal_heights() |
408 | 417 | self._strip_text_y_background_equal_widths() |
409 | 418 |
|
410 | | - def _adjust_axis_text_x(self, justify: PlotTextJustifier): |
| 419 | + def _adjust_axis_text_x(self, justify: TextJustifier): |
411 | 420 | """ |
412 | 421 | Adjust x-axis text, justifying vertically as necessary |
413 | 422 | """ |
@@ -438,7 +447,7 @@ def to_vertical_axis_dimensions(value: float, ax: Axes) -> float: |
438 | 447 | text, va, -axis_text_row_height, 0, height=height |
439 | 448 | ) |
440 | 449 |
|
441 | | - def _adjust_axis_text_y(self, justify: PlotTextJustifier): |
| 450 | + def _adjust_axis_text_y(self, justify: TextJustifier): |
442 | 451 | """ |
443 | 452 | Adjust x-axis text, justifying horizontally as necessary |
444 | 453 | """ |
@@ -556,25 +565,6 @@ def _text_is_visible(text: Text) -> bool: |
556 | 565 | return text.get_visible() and text._text # type: ignore |
557 | 566 |
|
558 | 567 |
|
559 | | -class PlotTextJustifier(TextJustifier): |
560 | | - """ |
561 | | - Justify Text about a plot or it's panels |
562 | | - """ |
563 | | - |
564 | | - def __init__(self, spaces: PlotSideSpaces): |
565 | | - boundaries = JustifyBoundaries( |
566 | | - plot_left=spaces.l.plot_left, |
567 | | - plot_right=spaces.r.plot_right, |
568 | | - plot_bottom=spaces.b.plot_bottom, |
569 | | - plot_top=spaces.t.plot_top, |
570 | | - panel_left=spaces.l.panel_left, |
571 | | - panel_right=spaces.r.panel_right, |
572 | | - panel_bottom=spaces.b.panel_bottom, |
573 | | - panel_top=spaces.t.panel_top, |
574 | | - ) |
575 | | - super().__init__(spaces.plot.figure, boundaries) |
576 | | - |
577 | | - |
578 | 568 | def set_legends_position(legends: legend_artists, spaces: PlotSideSpaces): |
579 | 569 | """ |
580 | 570 | Place legend on the figure and justify is a required |
@@ -752,7 +742,17 @@ def set_plot_tag_position_in_margin(tag: Text, spaces: PlotSideSpaces): |
752 | 742 | tag.set_y(y) |
753 | 743 | tag.set_verticalalignment("bottom") |
754 | 744 |
|
755 | | - justify = PlotTextJustifier(spaces) |
| 745 | + justify = TextJustifier.from_boundaries( |
| 746 | + spaces.plot.figure, |
| 747 | + plot_left=spaces.l.plot_left, |
| 748 | + plot_right=spaces.r.plot_right, |
| 749 | + plot_bottom=spaces.b.plot_bottom, |
| 750 | + plot_top=spaces.t.plot_top, |
| 751 | + panel_left=spaces.l.panel_left, |
| 752 | + panel_right=spaces.r.panel_right, |
| 753 | + panel_bottom=spaces.b.panel_bottom, |
| 754 | + panel_top=spaces.t.panel_top, |
| 755 | + ) |
756 | 756 | if position in ("left", "right"): |
757 | 757 | justify.vertically_along_plot(tag, va) |
758 | 758 | elif position in ("top", "bottom"): |
|
0 commit comments