Skip to content

Commit 36fcfe5

Browse files
committed
change stickies to sticky_edges; clarify edge calculation in contour
1 parent 5f942c8 commit 36fcfe5

File tree

9 files changed

+32
-35
lines changed

9 files changed

+32
-35
lines changed

doc/api/artist_api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Margins and Autoscaling
4747
:toctree: _as_gen
4848
:nosignatures:
4949

50-
Artist.stickies
50+
Artist.sticky_edges
5151

5252
Clipping
5353
--------

lib/matplotlib/artist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __init__(self):
126126
self._snap = None
127127
self._sketch = rcParams['path.sketch']
128128
self._path_effects = rcParams['path.effects']
129-
self._stickies = _XYPair([], [])
129+
self._sticky_edges = _XYPair([], [])
130130

131131
def __getstate__(self):
132132
d = self.__dict__.copy()
@@ -929,14 +929,14 @@ def set_zorder(self, level):
929929
self.stale = True
930930

931931
@property
932-
def stickies(self):
932+
def sticky_edges(self):
933933
"""
934934
The `x` and `y` sticky lists for the artist.
935935
936936
This attribute cannot be assigned to; however, the `x` and `y` lists
937937
can be modified in place as needed.
938938
"""
939-
return self._stickies
939+
return self._sticky_edges
940940

941941
def update_from(self, other):
942942
'Copy properties from *other* to *self*.'

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,9 +2125,9 @@ def make_iterable(x):
21252125
r.update(kwargs)
21262126
r.get_path()._interpolation_steps = 100
21272127
if orientation == 'vertical':
2128-
r.stickies.y.append(0)
2128+
r.sticky_edges.y.append(0)
21292129
elif orientation == 'horizontal':
2130-
r.stickies.x.append(0)
2130+
r.sticky_edges.x.append(0)
21312131
self.add_patch(r)
21322132
patches.append(r)
21332133

@@ -5483,8 +5483,8 @@ def pcolor(self, *args, **kwargs):
54835483

54845484
self.add_collection(collection, autolim=False)
54855485
corners = (minx, miny), (maxx, maxy)
5486-
collection.stickies.x[:] = [minx, maxx]
5487-
collection.stickies.y[:] = [miny, maxy]
5486+
collection.sticky_edges.x[:] = [minx, maxx]
5487+
collection.sticky_edges.y[:] = [miny, maxy]
54885488
self.update_datalim(corners)
54895489
self.autoscale_view()
54905490
return collection
@@ -5635,8 +5635,8 @@ def pcolormesh(self, *args, **kwargs):
56355635

56365636
self.add_collection(collection, autolim=False)
56375637
corners = (minx, miny), (maxx, maxy)
5638-
collection.stickies.x[:] = [minx, maxx]
5639-
collection.stickies.y[:] = [miny, maxy]
5638+
collection.sticky_edges.x[:] = [minx, maxx]
5639+
collection.sticky_edges.y[:] = [miny, maxy]
56405640
self.update_datalim(corners)
56415641
self.autoscale_view()
56425642
return collection
@@ -5825,8 +5825,8 @@ def pcolorfast(self, *args, **kwargs):
58255825
ret.set_clim(vmin, vmax)
58265826
else:
58275827
ret.autoscale_None()
5828-
ret.stickies.x[:] = [xl, xr]
5829-
ret.stickies.y[:] = [yb, yt]
5828+
ret.sticky_edges.x[:] = [xl, xr]
5829+
ret.sticky_edges.y[:] = [yb, yt]
58305830
self.update_datalim(np.array([[xl, yb], [xr, yt]]))
58315831
self.autoscale_view(tight=True)
58325832
return ret
@@ -6379,9 +6379,9 @@ def _normalize_input(inp, ename='input'):
63796379
for patch_list in patches:
63806380
for patch in patch_list:
63816381
if orientation == 'vertical':
6382-
patch.stickies.y.append(minimum)
6382+
patch.sticky_edges.y.append(minimum)
63836383
elif orientation == 'horizontal':
6384-
patch.stickies.x.append(minimum)
6384+
patch.sticky_edges.x.append(minimum)
63856385

63866386
# we return patches, so put it back in the expected order
63876387
patches.reverse()

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2203,7 +2203,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
22032203
self._tight = bool(tight)
22042204

22052205
if self._xmargin or self._ymargin:
2206-
stickies = [artist.stickies for artist in self.get_children()]
2206+
stickies = [artist.sticky_edges for artist in self.get_children()]
22072207
x_stickies = sum([sticky.x for sticky in stickies], [])
22082208
y_stickies = sum([sticky.y for sticky in stickies], [])
22092209
if self.get_xscale().lower() == 'log':

lib/matplotlib/contour.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -964,11 +964,10 @@ def __init__(self, ax, *args, **kwargs):
964964
self.ax.add_collection(col, autolim=False)
965965
self.collections.append(col)
966966

967-
mins, maxs = self._stickies
968967
for col in self.collections:
969-
col.stickies.x[:] = [mins[0], maxs[0]]
970-
col.stickies.y[:] = [mins[1], maxs[1]]
971-
self.ax.update_datalim([mins, maxs])
968+
col.sticky_edges.x[:] = [self._mins[0], self._maxs[0]]
969+
col.sticky_edges.y[:] = [self._mins[1], self._maxs[1]]
970+
self.ax.update_datalim([self._mins, self._maxs])
972971
self.ax.autoscale_view(tight=True)
973972

974973
self.changed() # set the colors
@@ -1076,13 +1075,9 @@ def _process_args(self, *args, **kwargs):
10761075
raise ValueError('allkinds has different length to allsegs')
10771076

10781077
# Determine x,y bounds and update axes data limits.
1079-
mins = np.min(
1080-
[np.min(seg, axis=0) for segs in self.allsegs for seg in segs],
1081-
axis=0)
1082-
maxs = np.max(
1083-
[np.max(seg, axis=0) for segs in self.allsegs for seg in segs],
1084-
axis=0)
1085-
self._stickies = [mins, maxs]
1078+
points = np.concatenate(self.allsegs, axis=0)
1079+
self._mins = points.min(axis=0)
1080+
self._maxs = points.max(axis=0)
10861081

10871082
def _get_allsegs_and_allkinds(self):
10881083
"""
@@ -1437,7 +1432,8 @@ def _process_args(self, *args, **kwargs):
14371432
contour_generator = args[0].Cntr
14381433
else:
14391434
contour_generator = args[0]._contour_generator
1440-
self._stickies = args[0]._stickies
1435+
self._mins = args[0]._mins
1436+
self._maxs = args[0]._maxs
14411437
else:
14421438
self._corner_mask = kwargs.get('corner_mask', None)
14431439
if self._corner_mask is None:
@@ -1470,7 +1466,8 @@ def _process_args(self, *args, **kwargs):
14701466
x = transformed_pts[..., 0]
14711467
y = transformed_pts[..., 1]
14721468

1473-
self._stickies = [(ma.min(x), ma.min(y)), (ma.max(x), ma.max(y))]
1469+
self._mins = [ma.min(x), ma.min(y)]
1470+
self._maxs = [ma.max(x), ma.max(y)]
14741471

14751472
if self._corner_mask == 'legacy':
14761473
self.Cntr = contour_generator

lib/matplotlib/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,8 @@ def set_extent(self, extent):
740740
xmin, xmax, ymin, ymax = extent
741741
corners = (xmin, ymin), (xmax, ymax)
742742
self.axes.update_datalim(corners)
743-
self.stickies.x[:] = [xmin, xmax]
744-
self.stickies.y[:] = [ymin, ymax]
743+
self.sticky_edges.x[:] = [xmin, xmax]
744+
self.sticky_edges.y[:] = [ymin, ymax]
745745
if self.axes._autoscaleXon:
746746
self.axes.set_xlim((xmin, xmax), auto=None)
747747
if self.axes._autoscaleYon:

lib/matplotlib/stackplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def stackplot(axes, x, *args, **kwargs):
111111
coll = axes.fill_between(x, first_line, stack[0, :],
112112
facecolor=color, label=six.next(labels, None),
113113
**kwargs)
114-
coll.stickies.y[:] = [0]
114+
coll.sticky_edges.y[:] = [0]
115115
r = [coll]
116116

117117
# Color between array i-1 and array i

lib/matplotlib/streamplot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
217217

218218
lc = mcollections.LineCollection(
219219
streamlines, transform=transform, **line_kw)
220-
lc.stickies.x[:] = [grid.x_origin, grid.x_origin + grid.width]
221-
lc.stickies.y[:] = [grid.y_origin, grid.y_origin + grid.height]
220+
lc.sticky_edges.x[:] = [grid.x_origin, grid.x_origin + grid.width]
221+
lc.sticky_edges.y[:] = [grid.y_origin, grid.y_origin + grid.height]
222222
if use_multicolor_lines:
223223
lc.set_array(np.ma.hstack(line_colors))
224224
lc.set_cmap(cmap)

lib/matplotlib/tri/tricontour.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def _process_args(self, *args, **kwargs):
5050
else:
5151
tri, z = self._contour_args(args, kwargs)
5252
C = _tri.TriContourGenerator(tri.get_cpp_triangulation(), z)
53-
self._stickies = [(tri.x.min(), tri.y.min()),
54-
(tri.x.max(), tri.y.max())]
53+
self._mins = [tri.x.min(), tri.y.min()]
54+
self._maxs = [tri.x.max(), tri.y.max()]
5555
self.ax.autoscale_view()
5656

5757
self.cppContourGenerator = C

0 commit comments

Comments
 (0)