Skip to content

Backport PR #27346 on branch v3.8.x (DOC: Show and correct default alignment parameters in text.py) #27510

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
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
==============

Texts are aligned relative to their anchor point depending on the properties
``horizontalalignment`` and ``verticalalignment``.
``horizontalalignment`` (default: ``left``) and ``verticalalignment``
(default: ``baseline``.)

.. redirect-from:: /gallery/pyplots/text_layout

Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,10 @@ def text(self, x, y, s, fontdict=None, **kwargs):
"""
Add text to the Axes.

Add the text *s* to the Axes at location *x*, *y* in data coordinates.
Add the text *s* to the Axes at location *x*, *y* in data coordinates,
with a default ``horizontalalignment`` on the ``left`` and
``verticalalignment`` at the ``baseline``. See
:doc:`/gallery/text_labels_and_annotations/text_alignment`.

Parameters
----------
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def __init__(self,

The text is aligned relative to the anchor point (*x*, *y*) according
to ``horizontalalignment`` (default: 'left') and ``verticalalignment``
(default: 'bottom'). See also
(default: 'baseline'). See also
:doc:`/gallery/text_labels_and_annotations/text_alignment`.

While Text accepts the 'label' keyword argument, by default it is not
Expand Down Expand Up @@ -1251,7 +1251,7 @@ def set_verticalalignment(self, align):

Parameters
----------
align : {'bottom', 'baseline', 'center', 'center_baseline', 'top'}
align : {'baseline', 'bottom', 'center', 'center_baseline', 'top'}
"""
_api.check_in_list(
['top', 'bottom', 'center', 'baseline', 'center_baseline'],
Expand Down