Skip to content

Commit 7f3089f

Browse files
committed
Better document multilinebaseline.
Also set its default to False instead of None. (We only check truthiness, so False and None are equivalent.) Also don't explicitly set the default verticalalignment in textprops to "baseline" -- that is already the normal default of `Text`, and is thus redundant; moreover, the old implementation would cause property collision if "verticalalignment" (fully spelt out) was passed in instead (basically, a call to `normalize_kwargs` was missing). Also minor misc. docstring improvements.
1 parent da66560 commit 7f3089f

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -779,30 +779,26 @@ class TextArea(OffsetBox):
779779
@cbook._delete_parameter("3.4", "minimumdescent")
780780
def __init__(self, s,
781781
textprops=None,
782-
multilinebaseline=None,
782+
multilinebaseline=False,
783783
minimumdescent=True,
784784
):
785785
"""
786786
Parameters
787787
----------
788788
s : str
789789
The text to be displayed.
790-
791-
textprops : dict, optional
792-
Dictionary of keyword parameters to be passed to the
793-
`~matplotlib.text.Text` instance contained inside TextArea.
794-
795-
multilinebaseline : bool, optional
796-
If `True`, baseline for multiline text is adjusted so that it is
797-
(approximately) center-aligned with singleline text.
798-
790+
textprops : dict, default: {}
791+
Dictionary of keyword parameters to be passed to the `.Text`
792+
instance in the TextArea.
793+
multilinebaseline : bool, default: False
794+
Whether the baseline for multiline text is adjusted so that it
795+
is (approximately) center-aligned with single-line text.
799796
minimumdescent : bool, default: True
800797
If `True`, the box has a minimum descent of "p". This is now
801798
effectively always True.
802799
"""
803800
if textprops is None:
804801
textprops = {}
805-
textprops.setdefault("va", "baseline")
806802
self._text = mtext.Text(0, 0, s, **textprops)
807803
super().__init__()
808804
self._children = [self._text]
@@ -826,8 +822,10 @@ def set_multilinebaseline(self, t):
826822
"""
827823
Set multilinebaseline.
828824
829-
If True, baseline for multiline text is adjusted so that it is
830-
(approximately) center-aligned with single-line text.
825+
If True, the baseline for multiline text is adjusted so that it is
826+
(approximately) center-aligned with single-line text. This is used
827+
e.g. by the legend implementation so that single-line labels are
828+
baseline-aligned, but multiline labels are "center"-aligned with them.
831829
"""
832830
self._multilinebaseline = t
833831
self.stale = True

0 commit comments

Comments
 (0)