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

Skip to content

Commit de39c79

Browse files
committed
fix autoscaling bug in scatter resulting from 86774fc
autoscale_view() needs to be called after add_collection(), because the latter calls update_datalim()
1 parent 1fdc478 commit de39c79

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/matplotlib/axes.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5892,21 +5892,20 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
58925892
else:
58935893
collection.autoscale_None()
58945894

5895-
# the pad is a little hack to deal with the fact that we don't
5895+
# The margin adjustment is a hack to deal with the fact that we don't
58965896
# want to transform all the symbols whose scales are in points
58975897
# to data coords to get the exact bounding box for efficiency
5898-
# reasons. It can be done right if this is deemed important
5898+
# reasons. It can be done right if this is deemed important.
58995899
# Also, only bother with this padding if there is anything to draw.
59005900
if self._xmargin < 0.05 and x.size > 0 :
59015901
self.set_xmargin(0.05)
59025902

59035903
if self._ymargin < 0.05 and x.size > 0 :
59045904
self.set_ymargin(0.05)
59055905

5906+
self.add_collection(collection)
59065907
self.autoscale_view()
59075908

5908-
# add the collection last
5909-
self.add_collection(collection)
59105909
return collection
59115910

59125911
@docstring.dedent_interpd

0 commit comments

Comments
 (0)