Skip to content

Better document multilinebaseline (and other small TextArea fixes) #19015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,30 +779,26 @@ class TextArea(OffsetBox):
@cbook._delete_parameter("3.4", "minimumdescent")
def __init__(self, s,
textprops=None,
multilinebaseline=None,
multilinebaseline=False,
minimumdescent=True,
):
"""
Parameters
----------
s : str
The text to be displayed.

textprops : dict, optional
Dictionary of keyword parameters to be passed to the
`~matplotlib.text.Text` instance contained inside TextArea.

multilinebaseline : bool, optional
If `True`, baseline for multiline text is adjusted so that it is
(approximately) center-aligned with singleline text.

textprops : dict, default: {}
Dictionary of keyword parameters to be passed to the `.Text`
instance in the TextArea.
multilinebaseline : bool, default: False
Whether the baseline for multiline text is adjusted so that it
is (approximately) center-aligned with single-line text.
minimumdescent : bool, default: True
If `True`, the box has a minimum descent of "p". This is now
effectively always True.
"""
if textprops is None:
textprops = {}
textprops.setdefault("va", "baseline")
self._text = mtext.Text(0, 0, s, **textprops)
super().__init__()
self._children = [self._text]
Expand All @@ -826,8 +822,10 @@ def set_multilinebaseline(self, t):
"""
Set multilinebaseline.

If True, baseline for multiline text is adjusted so that it is
(approximately) center-aligned with single-line text.
If True, the baseline for multiline text is adjusted so that it is
(approximately) center-aligned with single-line text. This is used
e.g. by the legend implementation so that single-line labels are
baseline-aligned, but multiline labels are "center"-aligned with them.
"""
self._multilinebaseline = t
self.stale = True
Expand Down