Skip to content

Commit 5bf5273

Browse files
committed
Add private Artist-level autoscale participation flag
1 parent fbb623e commit 5bf5273

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

lib/matplotlib/artist.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def __init__(self):
225225
self._path_effects = mpl.rcParams['path.effects']
226226
self._sticky_edges = _XYPair([], [])
227227
self._in_layout = True
228+
self._in_autoscale = True
228229

229230
def __getstate__(self):
230231
d = self.__dict__.copy()
@@ -902,7 +903,17 @@ def get_in_layout(self):
902903
``fig.savefig(fname, bbox_inches='tight')``.
903904
"""
904905
return self._in_layout
906+
907+
def get_in_autoscale(self):
908+
"""
909+
Return boolean flag, ``True`` if artist is included in autoscaling
910+
calculations.
905911
912+
E.g. :ref:`autoscaling_guide` and
913+
`.Axes.relim()`.
914+
"""
915+
return self._in_autoscale
916+
906917
def _fully_clipped_to_axes(self):
907918
"""
908919
Return a boolean flag, ``True`` if the artist is clipped to the Axes
@@ -1132,6 +1143,18 @@ def set_in_layout(self, in_layout):
11321143
"""
11331144
self._in_layout = in_layout
11341145

1146+
def set_in_autoscale(self, in_autoscale):
1147+
"""
1148+
Set if artist is to be included in autoscaling calculations,
1149+
E.g. :ref:`autoscaling_guide` and
1150+
`.Axes.relim()`.
1151+
1152+
Parameters
1153+
----------
1154+
in_autoscale : bool
1155+
"""
1156+
self._in_autoscale = in_autoscale
1157+
11351158
def get_label(self):
11361159
"""Return the label used for this artist in the legend."""
11371160
return self._label

lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,15 +2606,15 @@ def relim(self, visible_only=False):
26062606

26072607
for artist in self._children:
26082608
if not visible_only or artist.get_visible():
2609+
if not artist.get_in_autoscale():
2610+
continue
26092611
if isinstance(artist, mlines.Line2D):
26102612
self._update_line_limits(artist)
26112613
elif isinstance(artist, mpatches.Patch):
26122614
self._update_patch_limits(artist)
26132615
elif isinstance(artist, mimage.AxesImage):
26142616
self._update_image_limits(artist)
2615-
elif isinstance(artist, mcollections.Collection):
2616-
self._update_collection_limits(artist)
2617-
2617+
26182618
def update_datalim(self, xys, updatex=True, updatey=True):
26192619
"""
26202620
Extend the `~.Axes.dataLim` Bbox to include the given points.

0 commit comments

Comments
 (0)