Skip to content

Commit 73640b5

Browse files
committed
scatter: disable the margin override except in classic mode
With margins by default in v2.x, removing this override makes for a simpler and more predictable API.
1 parent fb4b061 commit 73640b5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4043,16 +4043,16 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
40434043
else:
40444044
collection.autoscale_None()
40454045

4046-
# The margin adjustment is a hack to deal with the fact that we don't
4047-
# want to transform all the symbols whose scales are in points
4048-
# to data coords to get the exact bounding box for efficiency
4049-
# reasons. It can be done right if this is deemed important.
4050-
# Also, only bother with this padding if there is anything to draw.
4051-
if self._xmargin < 0.05 and x.size > 0:
4052-
self.set_xmargin(0.05)
4053-
4054-
if self._ymargin < 0.05 and x.size > 0:
4055-
self.set_ymargin(0.05)
4046+
# Classic mode only:
4047+
# ensure there are margins to allow for the
4048+
# finite size of the symbols. In v2.x, margins
4049+
# are present by default, so we disable this
4050+
# scatter-specific override.
4051+
if rcParams['_internal.classic_mode']:
4052+
if self._xmargin < 0.05 and x.size > 0:
4053+
self.set_xmargin(0.05)
4054+
if self._ymargin < 0.05 and x.size > 0:
4055+
self.set_ymargin(0.05)
40564056

40574057
self.add_collection(collection)
40584058
self.autoscale_view()

0 commit comments

Comments
 (0)