Skip to content

Commit cb8d3c5

Browse files
authored
Merge pull request #19015 from anntzer/textarea
Better document multilinebaseline (and other small TextArea fixes)
2 parents 2e6e491 + 7f3089f commit cb8d3c5

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

lib/matplotlib/offsetbox.py

+11-13
Original file line numberDiff line numberDiff line change
@@ -703,30 +703,26 @@ class TextArea(OffsetBox):
703703
@cbook._delete_parameter("3.4", "minimumdescent")
704704
def __init__(self, s,
705705
textprops=None,
706-
multilinebaseline=None,
706+
multilinebaseline=False,
707707
minimumdescent=True,
708708
):
709709
"""
710710
Parameters
711711
----------
712712
s : str
713713
The text to be displayed.
714-
715-
textprops : dict, optional
716-
Dictionary of keyword parameters to be passed to the
717-
`~matplotlib.text.Text` instance contained inside TextArea.
718-
719-
multilinebaseline : bool, optional
720-
If `True`, baseline for multiline text is adjusted so that it is
721-
(approximately) center-aligned with singleline text.
722-
714+
textprops : dict, default: {}
715+
Dictionary of keyword parameters to be passed to the `.Text`
716+
instance in the TextArea.
717+
multilinebaseline : bool, default: False
718+
Whether the baseline for multiline text is adjusted so that it
719+
is (approximately) center-aligned with single-line text.
723720
minimumdescent : bool, default: True
724721
If `True`, the box has a minimum descent of "p". This is now
725722
effectively always True.
726723
"""
727724
if textprops is None:
728725
textprops = {}
729-
textprops.setdefault("va", "baseline")
730726
self._text = mtext.Text(0, 0, s, **textprops)
731727
super().__init__()
732728
self._children = [self._text]
@@ -750,8 +746,10 @@ def set_multilinebaseline(self, t):
750746
"""
751747
Set multilinebaseline.
752748
753-
If True, baseline for multiline text is adjusted so that it is
754-
(approximately) center-aligned with single-line text.
749+
If True, the baseline for multiline text is adjusted so that it is
750+
(approximately) center-aligned with single-line text. This is used
751+
e.g. by the legend implementation so that single-line labels are
752+
baseline-aligned, but multiline labels are "center"-aligned with them.
755753
"""
756754
self._multilinebaseline = t
757755
self.stale = True

0 commit comments

Comments
 (0)