8000 DOC: Clarify axhline() uses axes coordinates · timhoffm/matplotlib@3afdea8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3afdea8

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

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

galleries/users_explain/artists/transforms_tutorial.py

Lines changed: 1 addition & 0 deletions
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

Original file line numberDiff line numberDiff line change
@@ -767,20 +767,26 @@ 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>` of the
779+
horizontal line.
776780
777781
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.
782+
The start position in :ref:`axes coordinates <coordinate-systems>`.
783+
Should be between 0 and 1, 0 being the far left of the plot,
784+
1 the far right of the plot.
780785
781786
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.
787+
The end position in :ref:`axes coordinates <coordinate-systems>`.
788+
Should be between 0 and 1, 0 being the far left of the plot,
789+
1 the far right of the plot.
784790
785791
Returns
786792
-------
@@ -836,18 +842,24 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
836842
@_docstring.dedent_interpd
837843
def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
838844
"""
839-
Add a vertical line across the Axes.
845+
Add a vertical line spanning the whole or fraction of the Axes.
846+
847+
Note: If you want to set y-limits in data coordinates, use
848+
`~.Axes.vlines` instead.
840849
841850
Parameters
842851
----------
843852
x : float, default: 0
844-
x position in data coordinates of the vertical line.
853+
y position in :ref:`data coordinates <coordinate-systems>` of the
854+
vertical line.
845855
846856
ymin : float, default: 0
857+
The start position in :ref:`axes coordinates <coordinate-systems>`.
847858
Should be between 0 and 1, 0 being the bottom of the plot, 1 the
848859
top of the plot.
849860
850861
ymax : float, default: 1
862+
The end position in :ref:`axes coordinates <coordinate-systems>`.
851863
Should be between 0 and 1, 0 being the bottom of the plot, 1 the
852864
top of the plot.
853865

0 commit comments

Comments
 (0)
0