Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Backport PR #29075 on branch v3.10.x (Add xaxis and yaxis attributes to Axes docs) #29663

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
6 changes: 6 additions & 0 deletions doc/api/axes_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,24 @@ Property cycle

Axes.set_prop_cycle

.. _axes-api-axis:

Axis / limits
=============

.. For families of methods of the form {get,set}_{x,y}foo, try to list them in
the order set_xfoo, get_xfoo, set_yfoo, get_yfoo

Axis access
-----------

.. autosummary::
:toctree: _as_gen
:template: autosummary.rst
:nosignatures:

Axes.xaxis
Axes.yaxis
Axes.get_xaxis
Axes.get_yaxis

Expand Down
34 changes: 32 additions & 2 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,36 @@ class _AxesBase(martist.Artist):
dataLim: mtransforms.Bbox
"""The bounding `.Bbox` enclosing all data displayed in the Axes."""

xaxis: maxis.XAxis
"""
The `.XAxis` instance.

Common axis-related configuration can be achieved through high-level wrapper
methods on Axes; e.g. `ax.set_xticks <.Axes.set_xticks>` is a shortcut for
`ax.xaxis.set_ticks <.Axis.set_ticks>`. The *xaxis* attribute gives direct
direct access to the underlying `~.axis.Axis` if you need more control.

See also

- :ref:`Axis wrapper methods on Axes <axes-api-axis>`
- :doc:`Axis API </api/axis_api>`
"""

yaxis: maxis.YAxis
"""
The `.YAxis` instance.

Common axis-related configuration can be achieved through high-level wrapper
methods on Axes; e.g. `ax.set_yticks <.Axes.set_yticks>` is a shortcut for
`ax.yaxis.set_ticks <.Axis.set_ticks>`. The *yaxis* attribute gives direct
access to the underlying `~.axis.Axis` if you need more control.

See also

- :ref:`Axis wrapper methods on Axes <axes-api-axis>`
- :doc:`Axis API </api/axis_api>`
"""

@property
def _axis_map(self):
"""A mapping of axis names, e.g. 'x', to `Axis` instances."""
Expand Down Expand Up @@ -2218,7 +2248,7 @@ def get_xaxis(self):
.. admonition:: Discouraged

The use of this function is discouraged. You should instead
directly access the attribute ``ax.xaxis``.
directly access the attribute `~.Axes.xaxis`.
"""
return self.xaxis

Expand All @@ -2229,7 +2259,7 @@ def get_yaxis(self):
.. admonition:: Discouraged

The use of this function is discouraged. You should instead
directly access the attribute ``ax.yaxis``.
directly access the attribute `~.Axes.yaxis`.
"""
return self.yaxis

Expand Down
Loading