Skip to content

Commit 132a463

Browse files
committed
Adding possibility to remove invisible lines and patches from relim
1 parent ddb4b45 commit 132a463

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,9 +1590,11 @@ def add_container(self, container):
15901590
container.set_remove_method(lambda h: self.containers.remove(h))
15911591
return container
15921592

1593-
def relim(self):
1593+
def relim(self, visible_only=False):
15941594
"""
1595-
Recompute the data limits based on current artists.
1595+
Recompute the data limits based on current artists. If you want to exclude
1596+
invisible artists from the calculation, set
1597+
`visible_only=True`
15961598
15971599
At present, :class:`~matplotlib.collections.Collection`
15981600
instances are not supported.
@@ -1604,10 +1606,12 @@ def relim(self):
16041606
self.ignore_existing_data_limits = True
16051607

16061608
for line in self.lines:
1607-
self._update_line_limits(line)
1609+
if not visible_only or line.get_visible():
1610+
self._update_line_limits(line)
16081611

16091612
for p in self.patches:
1610-
self._update_patch_limits(p)
1613+
if not visible_only or p.get_visible():
1614+
self._update_patch_limits(p)
16111615

16121616
def update_datalim(self, xys, updatex=True, updatey=True):
16131617
"""

0 commit comments

Comments
 (0)