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

Skip to content

Commit 50dd11c

Browse files
committed
DOC: Add a warning that ticks are not persistent
1 parent 4b1508f commit 50dd11c

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

lib/matplotlib/axis.py

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,18 @@ class Axis(martist.Artist):
619619
The acceptance radius for containment tests. See also `.Axis.contains`.
620620
majorTicks : list of `.Tick`
621621
The major ticks.
622+
623+
.. warning::
624+
625+
Ticks are not guaranteed to be persistent. Various operations
626+
can create, delete and modify the Tick instances. There is an
627+
imminent risk that changes to individual ticks will not
628+
survive if you work on the figure further (including also
629+
panning/zooming on a displayed figure).
630+
631+
Working on the individual ticks is a method of last resort.
632+
Use `.set_tick_params` instead if possible.
633+
622634
minorTicks : list of `.Tick`
623635
The minor ticks.
624636
"""
@@ -1591,7 +1603,20 @@ def get_minor_formatter(self):
15911603
return self.minor.formatter
15921604

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

@@ -1604,7 +1629,20 @@ def get_major_ticks(self, numticks=None):
16041629
return self.majorTicks[:numticks]
16051630

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

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

lib/matplotlib/projections/polar.py

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

0 commit comments

Comments
 (0)