diff --git a/lib/matplotlib/path.py b/lib/matplotlib/path.py index 6f626d1469b3..93165dc684dc 100644 --- a/lib/matplotlib/path.py +++ b/lib/matplotlib/path.py @@ -330,13 +330,8 @@ def make_compound_path(cls, *args): if not args: return Path(np.empty([0, 2], dtype=np.float32)) - lengths = [len(x) for x in args] - total_length = sum(lengths) - - vertices = np.vstack([x.vertices for x in args]) - vertices.reshape((total_length, 2)) - - codes = np.empty(total_length, dtype=cls.code_type) + vertices = np.concatenate([x.vertices for x in args]) + codes = np.empty(len(vertices), dtype=cls.code_type) i = 0 for path in args: if path.codes is None: diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index 6756ff3759fc..7ced370d565b 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -2176,10 +2176,9 @@ def get_affine(self): else: x_mtx = self._x.get_affine().get_matrix() y_mtx = self._y.get_affine().get_matrix() - # This works because we already know the transforms are - # separable, though normally one would want to set b and - # c to zero. - mtx = np.vstack((x_mtx[0], y_mtx[1], [0.0, 0.0, 1.0])) + # We already know the transforms are separable, so we can skip + # setting b and c to zero. + mtx = np.array([x_mtx[0], y_mtx[1], [0.0, 0.0, 1.0]]) self._affine = Affine2D(mtx) self._invalid = 0 return self._affine @@ -2229,10 +2228,9 @@ def get_matrix(self): else: x_mtx = self._x.get_matrix() y_mtx = self._y.get_matrix() - # This works because we already know the transforms are - # separable, though normally one would want to set b and - # c to zero. - self._mtx = np.vstack((x_mtx[0], y_mtx[1], [0.0, 0.0, 1.0])) + # We already know the transforms are separable, so we can skip + # setting b and c to zero. + self._mtx = np.array([x_mtx[0], y_mtx[1], [0.0, 0.0, 1.0]]) self._inverted = None self._invalid = 0 return self._mtx