Skip to content

Commit

Permalink
DOC: Add a warning that ticks are not persistent
Browse files Browse the repository at this point in the history
  • Loading branch information
timhoffm committed Aug 2, 2023
1 parent 4b1508f commit 218ab59
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,18 @@ class Axis(martist.Artist):
The acceptance radius for containment tests. See also `.Axis.contains`.
majorTicks : list of `.Tick`
The major ticks.
.. warning::
Ticks are not guaranteed to be persistent. Various operations
can create, delete and modify the Tick instances. There is an
imminent risk that changes to individual ticks will not
survive if you work on the figure further (including also
panning/zooming on a displayed figure).
Working on the individual ticks is a method of last resort.
Use `.set_tick_params` instead if possible.
minorTicks : list of `.Tick`
The minor ticks.
"""
Expand Down Expand Up @@ -1591,7 +1603,20 @@ def get_minor_formatter(self):
return self.minor.formatter

def get_major_ticks(self, numticks=None):
r"""Return the list of major `.Tick`\s."""
r"""
Return the list of major `.Tick`\s.
.. warning::
Ticks are not guaranteed to be persistent. Various operations
can create, delete and modify the Tick instances. There is an
imminent risk that changes to individual ticks will not
survive if you work on the figure further (including also
panning/zooming on a displayed figure).
Working on the individual ticks is a method of last resort.
Use `.set_tick_params` instead if possible.
"""
if numticks is None:
numticks = len(self.get_majorticklocs())

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

def get_minor_ticks(self, numticks=None):
r"""Return the list of minor `.Tick`\s."""
r"""
Return the list of minor `.Tick`\s.
.. warning::
Ticks are not guaranteed to be persistent. Various operations
can create, delete and modify the Tick instances. There is an
imminent risk that changes to individual ticks will not
survive if you work on the figure further (including also
panning/zooming on a displayed figure).
Working on the individual ticks is a method of last resort.
Use `.set_tick_params` instead if possible.
"""
if numticks is None:
numticks = len(self.get_minorticklocs())

Expand Down

0 comments on commit 218ab59

Please sign in to comment.