Skip to content

Commit eb4b1ee

Browse files
authored
Merge pull request #26439 from meeseeksmachine/auto-backport-of-pr-26436-on-v3.7.x
Backport PR #26436 on branch v3.7.x (DOC: Add a warning that ticks are not persistent)
2 parents f3b881f + 53211a6 commit eb4b1ee

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

lib/matplotlib/axis.py

+51-2
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,18 @@ class Axis(martist.Artist):
628628
The acceptance radius for containment tests. See also `.Axis.contains`.
629629
majorTicks : list of `.Tick`
630630
The major ticks.
631+
632+
.. warning::
633+
634+
Ticks are not guaranteed to be persistent. Various operations
635+
can create, delete and modify the Tick instances. There is an
636+
imminent risk that changes to individual ticks will not
637+
survive if you work on the figure further (including also
638+
panning/zooming on a displayed figure).
639+
640+
Working on the individual ticks is a method of last resort.
641+
Use `.set_tick_params` instead if possible.
642+
631643
minorTicks : list of `.Tick`
632644
The minor ticks.
633645
"""
@@ -1593,7 +1605,20 @@ def get_minor_formatter(self):
15931605
return self.minor.formatter
15941606

15951607
def get_major_ticks(self, numticks=None):
1596-
r"""Return the list of major `.Tick`\s."""
1608+
r"""
1609+
Return the list of major `.Tick`\s.
1610+
1611+
.. warning::
1612+
1613+
Ticks are not guaranteed to be persistent. Various operations
1614+
can create, delete and modify the Tick instances. There is an
1615+
imminent risk that changes to individual ticks will not
1616+
survive if you work on the figure further (including also
1617+
panning/zooming on a displayed figure).
1618+
1619+
Working on the individual ticks is a method of last resort.
1620+
Use `.set_tick_params` instead if possible.
1621+
"""
15971622
if numticks is None:
15981623
numticks = len(self.get_majorticklocs())
15991624

@@ -1606,7 +1631,20 @@ def get_major_ticks(self, numticks=None):
16061631
return self.majorTicks[:numticks]
16071632

16081633
def get_minor_ticks(self, numticks=None):
1609-
r"""Return the list of minor `.Tick`\s."""
1634+
r"""
1635+
Return the list of minor `.Tick`\s.
1636+
1637+
.. warning::
1638+
1639+
Ticks are not guaranteed to be persistent. Various operations
1640+
can create, delete and modify the Tick instances. There is an
1641+
imminent risk that changes to individual ticks will not
1642+
survive if you work on the figure further (including also
1643+
panning/zooming on a displayed figure).
1644+
1645+
Working on the individual ticks is a method of last resort.
1646+
Use `.set_tick_params` instead if possible.
1647+
"""
16101648
if numticks is None:
16111649
numticks = len(self.get_minorticklocs())
16121650

@@ -1949,6 +1987,17 @@ def set_ticklabels(self, labels, *, minor=False, fontdict=None, **kwargs):
19491987
**kwargs
19501988
Text properties.
19511989
1990+
.. warning::
1991+
1992+
This only sets the properties of the current ticks.
1993+
Ticks are not guaranteed to be persistent. Various operations
1994+
can create, delete and modify the Tick instances. There is an
1995+
imminent risk that these settings can get lost if you work on
1996+
the figure further (including also panning/zooming on a
1997+
displayed figure).
1998+
1999+
Use `.set_tick_params` instead if possible.
2000+
19522001
Returns
19532002
-------
19542003
list of `.Text`\s

lib/matplotlib/projections/polar.py

+22
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,17 @@ def set_thetagrids(self, angles, labels=None, fmt=None, **kwargs):
13181318
**kwargs
13191319
*kwargs* are optional `.Text` properties for the labels.
13201320
1321+
.. warning::
1322+
1323+
This only sets the properties of the current ticks.
1324+
Ticks are not guaranteed to be persistent. Various operations
1325+
can create, delete and modify the Tick instances. There is an
1326+
imminent risk that these settings can get lost if you work on
1327+
the figure further (including also panning/zooming on a
1328+
displayed figure).
1329+
1330+
Use `.set_tick_params` instead if possible.
1331+
13211332
See Also
13221333
--------
13231334
.PolarAxes.set_rgrids
@@ -1370,6 +1381,17 @@ def set_rgrids(self, radii, labels=None, angle=None, fmt=None, **kwargs):
13701381
**kwargs
13711382
*kwargs* are optional `.Text` properties for the labels.
13721383
1384+
.. warning::
1385+
1386+
This only sets the properties of the current ticks.
1387+
Ticks are not guaranteed to be persistent. Various operations
1388+
can create, delete and modify the Tick instances. There is an
1389+
imminent risk that these settings can get lost if you work on
1390+
the figure further (including also panning/zooming on a
1391+
displayed figure).
1392+
1393+
Use `.set_tick_params` instead if possible.
1394+
13731395
See Also
13741396
--------
13751397
.PolarAxes.set_thetagrids

0 commit comments

Comments
 (0)