Skip to content

Commit ce0fdbb

Browse files
committed
refactor: #28701 attempt to simplify make_verts_per_region
1 parent 84c5e55 commit ce0fdbb

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/matplotlib/collections.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,7 @@ def _make_verts(self, t, f1, f2, where, interpolate, step):
14421442
for idx0, idx1 in cbook.contiguous_regions(where)
14431443
]
14441444

1445+
# prepare the datalim for autoscale
14451446
bbox = transforms.Bbox.null()
14461447
bbox.update_from_data_xy(self._normalize_pts(np.vstack([
14471448
np.hstack([t[where, None], f[where, None]]) for f in (f1, f2)])))
@@ -1461,9 +1462,6 @@ def _make_verts_per_region(self, t, f1, f2, idx0, idx1, step, interpolate):
14611462
step_func = cbook.STEP_LOOKUP_MAP["steps-" + step]
14621463
t_slice, f1_slice, f2_slice = step_func(t_slice, f1_slice, f2_slice)
14631464

1464-
size = len(t_slice)
1465-
pts = np.zeros((2 * size + 2, 2))
1466-
14671465
if interpolate:
14681466
start = self._get_interp_point(t, f1, f2, idx0)
14691467
end = self._get_interp_point(t, f1, f2, idx1)
@@ -1473,13 +1471,11 @@ def _make_verts_per_region(self, t, f1, f2, idx0, idx1, step, interpolate):
14731471
start = t_slice[0], f2_slice[0]
14741472
end = t_slice[-1], f2_slice[-1]
14751473

1476-
pts[0] = start
1477-
pts[size + 1] = end
1478-
1479-
pts[1:size+1, 0] = t_slice
1480-
pts[1:size+1, 1] = f1_slice
1481-
pts[size+2:, 0] = t_slice[::-1]
1482-
pts[size+2:, 1] = f2_slice[::-1]
1474+
pts = np.concatenate((
1475+
np.asarray([start]),
1476+
np.stack((t_slice, f1_slice), axis=-1),
1477+
np.asarray([end]),
1478+
np.stack((t_slice, f2_slice), axis=-1)[::-1]))
14831479

14841480
return self._normalize_pts(pts)
14851481

0 commit comments

Comments
 (0)