Skip to content

Commit 60d2f95

Browse files
authored
DOC: Show and correct default alignment parameters in text.py (#27346)
* Show and correct default alignment parameters in text.py For issue [Doc]: text alignment defaults #27345 * Update text.py: line too long * Show defaults in text_alignment.py * Make setter method defaults match new docstrings in text.py See #27346 (review) * IDL text alignment set_ method defaults for text.pyi * revert interface defaults in text.pyi * revert defaults in alignment set_ methods text.py did change the order of allowed arguments for set_verticalalignment per @StefRe * Document text alignment defaults in _axes.py Because this is where the header at https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.text.html comes from. * rm trailing whitespace in _axes.py
1 parent 1c6fb79 commit 60d2f95

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

galleries/examples/text_labels_and_annotations/text_alignment.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
==============
55
66
Texts are aligned relative to their anchor point depending on the properties
7-
``horizontalalignment`` and ``verticalalignment``.
7+
``horizontalalignment`` (default: ``left``) and ``verticalalignment``
8+
(default: ``baseline``.)
89
910
.. redirect-from:: /gallery/pyplots/text_layout
1011

lib/matplotlib/axes/_axes.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,10 @@ def text(self, x, y, s, fontdict=None, **kwargs):
632632
"""
633633
Add text to the Axes.
634634
635-
Add the text *s* to the Axes at location *x*, *y* in data coordinates.
635+
Add the text *s* to the Axes at location *x*, *y* in data coordinates,
636+
with a default ``horizontalalignment`` on the ``left`` and
637+
``verticalalignment`` at the ``baseline``. See
638+
:doc:`/gallery/text_labels_and_annotations/text_alignment`.
636639
637640
Parameters
638641
----------

lib/matplotlib/text.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def __init__(self,
123123
124124
The text is aligned relative to the anchor point (*x*, *y*) according
125125
to ``horizontalalignment`` (default: 'left') and ``verticalalignment``
126-
(default: 'bottom'). See also
126+
(default: 'baseline'). See also
127127
:doc:`/gallery/text_labels_and_annotations/text_alignment`.
128128
129129
While Text accepts the 'label' keyword argument, by default it is not
@@ -1251,7 +1251,7 @@ def set_verticalalignment(self, align):
12511251
12521252
Parameters
12531253
----------
1254-
align : {'bottom', 'baseline', 'center', 'center_baseline', 'top'}
1254+
align : {'baseline', 'bottom', 'center', 'center_baseline', 'top'}
12551255
"""
12561256
_api.check_in_list(
12571257
['top', 'bottom', 'center', 'baseline', 'center_baseline'],

0 commit comments

Comments
 (0)