Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 49e122d

Browse filesBrowse files
committed
Add xaxis and yaxis attributes to Axes docs
1 parent ac75741 commit 49e122d
Copy full SHA for 49e122d

File tree

2 files changed

+41
-4
lines changed
Filter options

2 files changed

+41
-4
lines changed

‎doc/api/axes_api.rst

Copy file name to clipboardExpand all lines: doc/api/axes_api.rst
+6Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+35-4Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,36 @@ class _AxesBase(martist.Artist):
565565
dataLim: mtransforms.Bbox
566566
"""The bounding `.Bbox` enclosing all data displayed in the Axes."""
567567

568+
xaxis: maxis.XAxis
569+
"""
570+
The `.XAxis` instance.
571+
572+
Common axis-related configuration can be achieved through high-level wrapper
573+
methods on Axes; e.g. `ax.set_xticks <.Axes.set_xticks>` is a shortcut for
574+
`ax.xaxis.set_ticks <.axis.Axis.set_ticks>`. The *xaxis* attribute gives direct
575+
direct access to the underlying `.Axis` if you need more control.
576+
577+
See also
578+
579+
- :ref:`Axis wrapper methods on Axes <axes-api-axis>`
580+
- :doc:`Axis API </api/axis_api>`
581+
"""
582+
583+
yaxis: maxis.YAxis
584+
"""
585+
The `.YAxis` instance.
586+
587+
Common axis-related configuration can be achieved through high-level wrapper
588+
methods on Axes; e.g. `ax.set_yticks <.Axes.set_yticks>` is a shortcut for
589+
`ax.yaxis.set_ticks <.axis.Axis.set_ticks>`. The *yaxis* attribute gives direct
590+
access to the underlying `.Axis` if you need more control.
591+
592+
See also
593+
594+
- :ref:`Axis wrapper methods on Axes <axes-api-axis>`
595+
- :doc:`Axis API </api/axis_api>`
596+
"""
597+
568598
def __str__(self):
569599
return "{0}({1[0]:g},{1[1]:g};{1[2]:g}x{1[3]:g})".format(
570600
type(self).__name__, self._position.bounds)
@@ -677,8 +707,9 @@ def __init__(self, fig,
677707
self._colorbars = []
678708
self.spines = mspines.Spines.from_dict(self._gen_axes_spines())
679709

680-
# this call may differ for non-sep axes, e.g., polar
681-
self._init_axis()
710+
self.xaxis = None # will be populated in _init_axis()
711+
self.yaxis = None # will be populated in _init_axis()
712+
self._init_axis() # this call may differ for non-sep axes, e.g., polar
682713
self._axis_map = {
683714
name: getattr(self, f"{name}axis") for name in self._axis_names
684715
} # A mapping of axis names, e.g. 'x', to `Axis` instances.
@@ -2212,7 +2243,7 @@ def get_xaxis(self):
22122243
.. admonition:: Discouraged
22132244
22142245
The use of this function is discouraged. You should instead
2215-
directly access the attribute ``ax.xaxis``.
2246+
directly access the attribute `~.Axes.xaxis`.
22162247
"""
22172248
return self.xaxis
22182249

@@ -2223,7 +2254,7 @@ def get_yaxis(self):
22232254
.. admonition:: Discouraged
22242255
22252256
The use of this function is discouraged. You should instead
2226-
directly access the attribute ``ax.yaxis``.
2257+
directly access the attribute `~.Axes.yaxis`.
22272258
"""
22282259
return self.yaxis
22292260

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.