Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3014,15 +3014,17 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
x_stickies = y_stickies = np.array([])
if self.use_sticky_edges:
if self._xmargin and scalex and self.get_autoscalex_on():
x_stickies = np.sort(np.concatenate([
artist.sticky_edges.x
for ax in self._shared_axes["x"].get_siblings(self)
for artist in ax.get_children()]))
edges = []
for ax in self._shared_axes["x"].get_siblings(self):
for artist in ax.get_children():
edges.extend(artist.sticky_edges.x)
x_stickies = np.sort(edges)
if self._ymargin and scaley and self.get_autoscaley_on():
y_stickies = np.sort(np.concatenate([
artist.sticky_edges.y
for ax in self._shared_axes["y"].get_siblings(self)
for artist in ax.get_children()]))
edges = []
for ax in self._shared_axes["y"].get_siblings(self):
for artist in ax.get_children():
edges.extend(artist.sticky_edges.y)
y_stickies = np.sort(edges)
if self.get_xscale() == 'log':
x_stickies = x_stickies[x_stickies > 0]
if self.get_yscale() == 'log':
Expand Down
24 changes: 17 additions & 7 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1511,8 +1511,15 @@ def _make_verts(self, t, f1, f2, where):
t, f1, f2 = np.broadcast_arrays(np.atleast_1d(t), f1, f2, subok=True)

self._bbox = transforms.Bbox.null()
self._bbox.update_from_data_xy(self._fix_pts_xy_order(np.concatenate([
np.stack((t[where], f[where]), axis=-1) for f in (f1, f2)])))
t_where = t.data[where] if np.ma.isMA(t) else t[where]
f1_where = f1.data[where] if np.ma.isMA(f1) else f1[where]
f2_where = f2.data[where] if np.ma.isMA(f2) else f2[where]
n = len(t_where)
if n > 0:
pts = np.empty((2 * n, 2)) # Preallocate and fill for speed
pts[:n, 0], pts[:n, 1] = t_where, f1_where
pts[n:, 0], pts[n:, 1] = t_where, f2_where
self._bbox.update_from_data_xy(self._fix_pts_xy_order(pts))

return [
self._make_verts_for_region(t, f1, f2, idx0, idx1)
Expand Down Expand Up @@ -1570,11 +1577,14 @@ def _make_verts_for_region(self, t, f1, f2, idx0, idx1):
start = t_slice[0], f2_slice[0]
end = t_slice[-1], f2_slice[-1]

pts = np.concatenate((
np.asarray([start]),
np.stack((t_slice, f1_slice), axis=-1),
np.asarray([end]),
np.stack((t_slice, f2_slice), axis=-1)[::-1]))
# Build polygon: start -> along f1 -> end -> back along f2 (reversed)
# Preallocate and fill for speed
n = len(t_slice)
pts = np.empty((2 * n + 2, 2))
pts[0, :] = start
pts[1:n+1, 0], pts[1:n+1, 1] = t_slice, f1_slice
pts[n+1, :] = end
pts[n+2:, 0], pts[n+2:, 1] = t_slice[::-1], f2_slice[::-1]

return self._fix_pts_xy_order(pts)

Expand Down
17 changes: 12 additions & 5 deletions lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,12 @@ def recache(self, always=False):
interpolation_steps = self._path._interpolation_steps
else:
interpolation_steps = 1
xy = STEP_LOOKUP_MAP[self._drawstyle](*self._xy.T)
self._path = Path(np.asarray(xy).T,
_interpolation_steps=interpolation_steps)
if self._drawstyle == 'default':
vertices = self._xy
else:
step_func = STEP_LOOKUP_MAP[self._drawstyle]
vertices = np.asarray(step_func(*self._xy.T)).T
self._path = Path(vertices, _interpolation_steps=interpolation_steps)
self._transformed_path = None
self._invalidx = False
self._invalidy = False
Expand All @@ -724,8 +727,12 @@ def _transform_path(self, subslice=None):
"""
# Masked arrays are now handled by the Path class itself
if subslice is not None:
xy = STEP_LOOKUP_MAP[self._drawstyle](*self._xy[subslice, :].T)
_path = Path(np.asarray(xy).T,
if self._drawstyle == 'default':
vertices = self._xy[subslice]
else:
step_func = STEP_LOOKUP_MAP[self._drawstyle]
vertices = np.asarray(step_func(*self._xy[subslice, :].T)).T
_path = Path(vertices,
_interpolation_steps=self._path._interpolation_steps)
else:
_path = self._path
Expand Down
16 changes: 12 additions & 4 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,14 +904,22 @@ def update_from_path(self, path, ignore=None, updatex=True, updatey=True):

if updatex:
x = path.vertices[..., 0][valid_points]
points[0, 0] = min(points[0, 0], np.min(x, initial=np.inf))
minx = np.min(x, initial=np.inf)
points[0, 0] = min(points[0, 0], minx)
points[1, 0] = max(points[1, 0], np.max(x, initial=-np.inf))
minpos[0] = min(minpos[0], np.min(x[x > 0], initial=np.inf))
if minx > 0: # Fast path for all-positive x values
minpos[0] = min(minpos[0], minx)
else:
minpos[0] = min(minpos[0], np.min(x[x > 0], initial=np.inf))
if updatey:
y = path.vertices[..., 1][valid_points]
points[0, 1] = min(points[0, 1], np.min(y, initial=np.inf))
miny = np.min(y, initial=np.inf)
points[0, 1] = min(points[0, 1], miny)
points[1, 1] = max(points[1, 1], np.max(y, initial=-np.inf))
minpos[1] = min(minpos[1], np.min(y[y > 0], initial=np.inf))
if miny > 0: # Fast path for all-positive y values
minpos[1] = min(minpos[1], miny)
else:
minpos[1] = min(minpos[1], np.min(y[y > 0], initial=np.inf))

if np.any(points != self._points) or np.any(minpos != self._minpos):
self.invalidate()
Expand Down
Loading