Skip to content

Commit 218ab59

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

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

lib/matplotlib/axis.py

Lines changed: 40 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

0 commit comments

Comments
 (0)