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

Skip to content

Commit 06786f7

Browse files
committed
Only propagate minpos if it's been set.
This is mostly for the sake of third-party `Collection` subclasses that might have overridden `get_datalim`.
1 parent 279ec45 commit 06786f7

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

lib/matplotlib/axes/_base.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,12 +2001,15 @@ def add_collection(self, collection, autolim=True):
20012001
# pre-lazy-autoscale behavior, which is not really better).
20022002
self._unstale_viewLim()
20032003
datalim = collection.get_datalim(self.transData)
2004-
# By definition, p0 <= minpos <= p1, so minpos would be
2005-
# unnecessary. However, we add minpos to the call so that
2006-
# self.dataLim will update its own minpos. This ensures that log
2007-
# scales see the correct minimum.
2008-
self.update_datalim(
2009-
np.row_stack([datalim.p0, datalim.minpos, datalim.p1]))
2004+
points = datalim.get_points()
2005+
if not np.isinf(datalim.minpos).all():
2006+
# By definition, if minpos (minimum positive value) is set
2007+
# (i.e., non-inf), then min(points) <= minpos <= max(points),
2008+
# and minpos would be superfluous. However, we add minpos to
2009+
# the call so that self.dataLim will update its own minpos.
2010+
# This ensures that log scales see the correct minimum.
2011+
points = np.concatenate([points, [datalim.minpos]])
2012+
self.update_datalim(points)
20102013

20112014
self.stale = True
20122015
return collection

0 commit comments

Comments
 (0)