Skip to content

DOC: Clarify axhline() uses axes coordinates #28720

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
Aug 14, 2024
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
1 change: 1 addition & 0 deletions galleries/users_explain/artists/transforms_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:class:`~matplotlib.figure.Figure` instance, and ``subfigure`` is a
:class:`~matplotlib.figure.SubFigure` instance.

.. _coordinate-systems:

+----------------+-----------------------------------+-----------------------------+
|Coordinate |Description |Transformation object |
Expand Down
26 changes: 18 additions & 8 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,20 +767,25 @@ def annotate(self, text, xy, xytext=None, xycoords='data', textcoords=None,
@_docstring.dedent_interpd
def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
"""
Add a horizontal line across the Axes.
Add a horizontal line spanning the whole or fraction of the Axes.

Note: If you want to set x-limits in data coordinates, use
`~.Axes.hlines` instead.

Parameters
----------
y : float, default: 0
y position in data coordinates of the horizontal line.
y position in :ref:`data coordinates <coordinate-systems>`.

xmin : float, default: 0
Should be between 0 and 1, 0 being the far left of the plot, 1 the
far right of the plot.
The start x-position in :ref:`axes coordinates <coordinate-systems>`.
Should be between 0 and 1, 0 being the far left of the plot,
1 the far right of the plot.

xmax : float, default: 1
Should be between 0 and 1, 0 being the far left of the plot, 1 the
far right of the plot.
The end x-position in :ref:`axes coordinates <coordinate-systems>`.
Should be between 0 and 1, 0 being the far left of the plot,
1 the far right of the plot.

Returns
-------
Expand Down Expand Up @@ -836,18 +841,23 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
@_docstring.dedent_interpd
def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
"""
Add a vertical line across the Axes.
Add a vertical line spanning the whole or fraction of the Axes.

Note: If you want to set y-limits in data coordinates, use
`~.Axes.vlines` instead.

Parameters
----------
x : float, default: 0
x position in data coordinates of the vertical line.
y position in :ref:`data coordinates <coordinate-systems>`.

ymin : float, default: 0
The start y-position in :ref:`axes coordinates <coordinate-systems>`.
Should be between 0 and 1, 0 being the bottom of the plot, 1 the
top of the plot.

ymax : float, default: 1
The end y-position in :ref:`axes coordinates <coordinate-systems>`.
Should be between 0 and 1, 0 being the bottom of the plot, 1 the
top of the plot.

Expand Down
Loading