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

Skip to content

Commit af1366c

Browse files
authored
Merge pull request #29663 from timhoffm/auto-backport-of-pr-29075-on-v3.10.x
Backport PR #29075 on branch v3.10.x (Add xaxis and yaxis attributes to Axes docs)
2 parents 73a28c9 + 46a33f6 commit af1366c

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

doc/api/axes_api.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,24 @@ Property cycle
262262

263263
Axes.set_prop_cycle
264264

265+
.. _axes-api-axis:
265266

266267
Axis / limits
267268
=============
268269

269270
.. For families of methods of the form {get,set}_{x,y}foo, try to list them in
270271
the order set_xfoo, get_xfoo, set_yfoo, get_yfoo
271272
273+
Axis access
274+
-----------
275+
272276
.. autosummary::
273277
:toctree: _as_gen
274278
:template: autosummary.rst
275279
:nosignatures:
276280

281+
Axes.xaxis
282+
Axes.yaxis
277283
Axes.get_xaxis
278284
Axes.get_yaxis
279285

lib/matplotlib/axes/_base.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,36 @@ class _AxesBase(martist.Artist):
566566
dataLim: mtransforms.Bbox
567567
"""The bounding `.Bbox` enclosing all data displayed in the Axes."""
568568

569+
xaxis: maxis.XAxis
570+
"""
571+
The `.XAxis` instance.
572+
573+
Common axis-related configuration can be achieved through high-level wrapper
574+
methods on Axes; e.g. `ax.set_xticks <.Axes.set_xticks>` is a shortcut for
575+
`ax.xaxis.set_ticks <.Axis.set_ticks>`. The *xaxis* attribute gives direct
576+
direct access to the underlying `~.axis.Axis` if you need more control.
577+
578+
See also
579+
580+
- :ref:`Axis wrapper methods on Axes <axes-api-axis>`
581+
- :doc:`Axis API </api/axis_api>`
582+
"""
583+
584+
yaxis: maxis.YAxis
585+
"""
586+
The `.YAxis` instance.
587+
588+
Common axis-related configuration can be achieved through high-level wrapper
589+
methods on Axes; e.g. `ax.set_yticks <.Axes.set_yticks>` is a shortcut for
590+
`ax.yaxis.set_ticks <.Axis.set_ticks>`. The *yaxis* attribute gives direct
591+
access to the underlying `~.axis.Axis` if you need more control.
592+
593+
See also
594+
595+
- :ref:`Axis wrapper methods on Axes <axes-api-axis>`
596+
- :doc:`Axis API </api/axis_api>`
597+
"""
598+
569599
@property
570600
def _axis_map(self):
571601
"""A mapping of axis names, e.g. 'x', to `Axis` instances."""
@@ -2218,7 +2248,7 @@ def get_xaxis(self):
22182248
.. admonition:: Discouraged
22192249
22202250
The use of this function is discouraged. You should instead
2221-
directly access the attribute ``ax.xaxis``.
2251+
directly access the attribute `~.Axes.xaxis`.
22222252
"""
22232253
return self.xaxis
22242254

@@ -2229,7 +2259,7 @@ def get_yaxis(self):
22292259
.. admonition:: Discouraged
22302260
22312261
The use of this function is discouraged. You should instead
2232-
directly access the attribute ``ax.yaxis``.
2262+
directly access the attribute `~.Axes.yaxis`.
22332263
"""
22342264
return self.yaxis
22352265

0 commit comments

Comments
 (0)