From 6374f3a25d9fb3f030fb5c0d3377bba50e6aa4c3 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 7 Feb 2019 20:14:15 +0100 Subject: [PATCH] Minor simplifications to scatter3d. The lines ``` xs, ys, zs = np.broadcast_arrays( *[np.ravel(np.ma.filled(t, np.nan)) for t in [xs, ys, zs]]) ``` at the top of the function ensure that zs is already broadcasted against xs, and always 1D (and thus iterable); hence, the later iterability check and broadcasting are unnecessary. --- lib/mpl_toolkits/mplot3d/axes3d.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 304f98babae8..9fe474ce9cd1 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -2361,17 +2361,13 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True, xs, ys, zs, s, c = cbook.delete_masked_points(xs, ys, zs, s, c) patches = super().scatter(xs, ys, s=s, c=c, *args, **kwargs) - is_2d = not np.iterable(zs) - zs = np.broadcast_to(zs, len(xs)) art3d.patch_collection_2d_to_3d(patches, zs=zs, zdir=zdir, depthshade=depthshade) if self._zmargin < 0.05 and xs.size > 0: self.set_zmargin(0.05) - #FIXME: why is this necessary? - if not is_2d: - self.auto_scale_xyz(xs, ys, zs, had_data) + self.auto_scale_xyz(xs, ys, zs, had_data) return patches