Skip to content

Commit 61d019b

Browse files
committed
DOC: Clarify axhline() uses axes coordinates
Closes #28612.
1 parent 315da10 commit 61d019b

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

galleries/users_explain/artists/transforms_tutorial.py

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
:class:`~matplotlib.figure.Figure` instance, and ``subfigure`` is a
2323
:class:`~matplotlib.figure.SubFigure` instance.
2424
25+
.. _coordinate-systems:
2526
2627
+----------------+-----------------------------------+-----------------------------+
2728
|Coordinate |Description |Transformation object |

lib/matplotlib/axes/_axes.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -767,20 +767,25 @@ def annotate(self, text, xy, xytext=None, xycoords='data', textcoords=None,
767767
@_docstring.dedent_interpd
768768
def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
769769
"""
770-
Add a horizontal line across the Axes.
770+
Add a horizontal line spanning the whole or fraction of the Axes.
771+
772+
Note: If you want to set x-limits in data coordinates, use
773+
`~.Axes.hlines` instead.
771774
772775
Parameters
773776
----------
774777
y : float, default: 0
775-
y position in data coordinates of the horizontal line.
778+
y position in :ref:`data coordinates <coordinate-systems>`.
776779
777780
xmin : float, default: 0
778-
Should be between 0 and 1, 0 being the far left of the plot, 1 the
779-
far right of the plot.
781+
The start x-position in :ref:`axes coordinates <coordinate-systems>`.
782+
Should be between 0 and 1, 0 being the far left of the plot,
783+
1 the far right of the plot.
780784
781785
xmax : float, default: 1
782-
Should be between 0 and 1, 0 being the far left of the plot, 1 the
783-
far right of the plot.
786+
The end x-position in :ref:`axes coordinates <coordinate-systems>`.
787+
Should be between 0 and 1, 0 being the far left of the plot,
788+
1 the far right of the plot.
784789
785790
Returns
786791
-------
@@ -836,18 +841,23 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
836841
@_docstring.dedent_interpd
837842
def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
838843
"""
839-
Add a vertical line across the Axes.
844+
Add a vertical line spanning the whole or fraction of the Axes.
845+
846+
Note: If you want to set y-limits in data coordinates, use
847+
`~.Axes.vlines` instead.
840848
841849
Parameters
842850
----------
843851
x : float, default: 0
844-
x position in data coordinates of the vertical line.
852+
y position in :ref:`data coordinates <coordinate-systems>`.
845853
846854
ymin : float, default: 0
855+
The start y-position in :ref:`axes coordinates <coordinate-systems>`.
847856
Should be between 0 and 1, 0 being the bottom of the plot, 1 the
848857
top of the plot.
849858
850859
ymax : float, default: 1
860+
The end y-position in :ref:`axes coordinates <coordinate-systems>`.
851861
Should be between 0 and 1, 0 being the bottom of the plot, 1 the
852862
top of the plot.
853863

0 commit comments

Comments
 (0)