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 0b50f1e

Browse filesBrowse files
authored
Merge pull request #26619 from timhoffm/doc-ticks-visible
[DOC] Clarify some tick-related docstrings
2 parents a7b47f4 + a2adf8b commit 0b50f1e
Copy full SHA for 0b50f1e

File tree

2 files changed

+47
-29
lines changed
Filter options

2 files changed

+47
-29
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+39-26Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,26 +2019,30 @@ def axis(self, arg=None, /, *, emit=True, **kwargs):
20192019
If a bool, turns axis lines and labels on or off. If a string,
20202020
possible values are:
20212021
2022-
======== ==========================================================
2023-
Value Description
2024-
======== ==========================================================
2025-
'on' Turn on axis lines and labels. Same as ``True``.
2026-
'off' Turn off axis lines and labels. Same as ``False``.
2027-
'equal' Set equal scaling (i.e., make circles circular) by
2028-
changing axis limits. This is the same as
2029-
``ax.set_aspect('equal', adjustable='datalim')``.
2030-
Explicit data limits may not be respected in this case.
2031-
'scaled' Set equal scaling (i.e., make circles circular) by
2032-
changing dimensions of the plot box. This is the same as
2033-
``ax.set_aspect('equal', adjustable='box', anchor='C')``.
2034-
Additionally, further autoscaling will be disabled.
2035-
'tight' Set limits just large enough to show all data, then
2036-
disable further autoscaling.
2037-
'auto' Automatic scaling (fill plot box with data).
2038-
'image' 'scaled' with axis limits equal to data limits.
2039-
'square' Square plot; similar to 'scaled', but initially forcing
2040-
``xmax-xmin == ymax-ymin``.
2041-
======== ==========================================================
2022+
================ ===========================================================
2023+
Value Description
2024+
================ ===========================================================
2025+
'off' or `False` Hide all axis decorations, i.e. axis labels, spines,
2026+
tick marks, tick labels, and grid lines.
2027+
This is the same as `~.Axes.set_axis_off()`.
2028+
'on' or `True` Do not hide all axis decorations, i.e. axis labels, spines,
2029+
tick marks, tick labels, and grid lines.
2030+
This is the same as `~.Axes.set_axis_on()`.
2031+
'equal' Set equal scaling (i.e., make circles circular) by
2032+
changing the axis limits. This is the same as
2033+
``ax.set_aspect('equal', adjustable='datalim')``.
2034+
Explicit data limits may not be respected in this case.
2035+
'scaled' Set equal scaling (i.e., make circles circular) by
2036+
changing dimensions of the plot box. This is the same as
2037+
``ax.set_aspect('equal', adjustable='box', anchor='C')``.
2038+
Additionally, further autoscaling will be disabled.
2039+
'tight' Set limits just large enough to show all data, then
2040+
disable further autoscaling.
2041+
'auto' Automatic scaling (fill plot box with data).
2042+
'image' 'scaled' with axis limits equal to data limits.
2043+
'square' Square plot; similar to 'scaled', but initially forcing
2044+
``xmax-xmin == ymax-ymin``.
2045+
================ ===========================================================
20422046
20432047
emit : bool, default: True
20442048
Whether observers are notified of the axis limit change.
@@ -3423,18 +3427,25 @@ def tick_params(self, axis='both', **kwargs):
34233427

34243428
def set_axis_off(self):
34253429
"""
3426-
Turn the x- and y-axis off.
3430+
Hide all visual components of the x- and y-axis.
34273431
3428-
This affects the axis lines, ticks, ticklabels, grid and axis labels.
3432+
This sets a flag to suppress drawing of all axis decorations, i.e.
3433+
axis labels, axis spines, and the axis tick component (tick markers,
3434+
tick labels, and grid lines). Individual visibility settings of these
3435+
components are ignored as long as `set_axis_off()` is in effect.
34293436
"""
34303437
self.axison = False
34313438
self.stale = True
34323439

34333440
def set_axis_on(self):
34343441
"""
3435-
Turn the x- and y-axis on.
3442+
Do not hide all visual components of the x- and y-axis.
34363443
3437-
This affects the axis lines, ticks, ticklabels, grid and axis labels.
3444+
This reverts the effect of a prior `.set_axis_off()` call. Whether the
3445+
individual axis decorations are drawn is controlled by their respective
3446+
visibility settings.
3447+
3448+
This is on by default.
34383449
"""
34393450
self.axison = True
34403451
self.stale = True
@@ -3681,7 +3692,8 @@ def set_xlim(self, left=None, right=None, *, emit=True, auto=False,
36813692
get_xscale = _axis_method_wrapper("xaxis", "get_scale")
36823693
set_xscale = _axis_method_wrapper("xaxis", "_set_axes_scale")
36833694
get_xticks = _axis_method_wrapper("xaxis", "get_ticklocs")
3684-
set_xticks = _axis_method_wrapper("xaxis", "set_ticks")
3695+
set_xticks = _axis_method_wrapper("xaxis", "set_ticks",
3696+
doc_sub={'set_ticks': 'set_xticks'})
36853697
get_xmajorticklabels = _axis_method_wrapper("xaxis", "get_majorticklabels")
36863698
get_xminorticklabels = _axis_method_wrapper("xaxis", "get_minorticklabels")
36873699
get_xticklabels = _axis_method_wrapper("xaxis", "get_ticklabels")
@@ -3912,7 +3924,8 @@ def set_ylim(self, bottom=None, top=None, *, emit=True, auto=False,
39123924
get_yscale = _axis_method_wrapper("yaxis", "get_scale")
39133925
set_yscale = _axis_method_wrapper("yaxis", "_set_axes_scale")
39143926
get_yticks = _axis_method_wrapper("yaxis", "get_ticklocs")
3915-
set_yticks = _axis_method_wrapper("yaxis", "set_ticks")
3927+
set_yticks = _axis_method_wrapper("yaxis", "set_ticks",
3928+
doc_sub={'set_ticks': 'set_yticks'})
39163929
get_ymajorticklabels = _axis_method_wrapper("yaxis", "get_majorticklabels")
39173930
get_yminorticklabels = _axis_method_wrapper("yaxis", "get_minorticklabels")
39183931
get_yticklabels = _axis_method_wrapper("yaxis", "get_ticklabels")

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,7 +2090,7 @@ def _set_tick_locations(self, ticks, *, minor=False):
20902090

20912091
def set_ticks(self, ticks, labels=None, *, minor=False, **kwargs):
20922092
"""
2093-
Set this Axis' tick locations and optionally labels.
2093+
Set this Axis' tick locations and optionally tick labels.
20942094
20952095
If necessary, the view limits of the Axis are expanded so that all
20962096
given ticks are visible.
@@ -2103,14 +2103,19 @@ def set_ticks(self, ticks, labels=None, *, minor=False, **kwargs):
21032103
21042104
The values may be either floats or in axis units.
21052105
2106+
Pass an empty list to remove all ticks::
2107+
2108+
set_ticks([])
2109+
21062110
Some tick formatters will not label arbitrary tick positions;
21072111
e.g. log formatters only label decade ticks by default. In
21082112
such a case you can set a formatter explicitly on the axis
21092113
using `.Axis.set_major_formatter` or provide formatted
21102114
*labels* yourself.
21112115
labels : list of str, optional
2112-
List of tick labels. If not set, the labels are generated with
2113-
the axis tick `.Formatter`.
2116+
Tick labels for each location in *ticks*. *labels* must be of the same
2117+
length as *ticks*. If not set, the labels are generate using the axis
2118+
tick `.Formatter`.
21142119
minor : bool, default: False
21152120
If ``False``, set the major ticks; if ``True``, the minor ticks.
21162121
**kwargs

0 commit comments

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