From 4d60247274e0d58ae14eb580594f2a01004fd57c Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sat, 25 Jul 2020 14:51:09 +0100 Subject: [PATCH] Only handle len > 0 facecolors in do_3d_projection --- lib/mpl_toolkits/mplot3d/art3d.py | 31 +++++++++++--------------- lib/mpl_toolkits/tests/test_mplot3d.py | 8 +++++++ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/lib/mpl_toolkits/mplot3d/art3d.py b/lib/mpl_toolkits/mplot3d/art3d.py index 0330efd78e51..f56aee41731c 100644 --- a/lib/mpl_toolkits/mplot3d/art3d.py +++ b/lib/mpl_toolkits/mplot3d/art3d.py @@ -487,33 +487,28 @@ def do_3d_projection(self, renderer): xs, ys, zs = self._offsets3d vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs, renderer.M) - fcs = (_zalpha(self._facecolor3d, vzs) if self._depthshade else - self._facecolor3d) - fcs = mcolors.to_rgba_array(fcs, self._alpha) - self.set_facecolors(fcs) - - ecs = (_zalpha(self._edgecolor3d, vzs) if self._depthshade else - self._edgecolor3d) - # Sort the points based on z coordinates # Performance optimization: Create a sorted index array and reorder # points and point properties according to the index array z_markers_idx = np.argsort(vzs)[::-1] - # Re-order items - vzs = vzs[z_markers_idx] - vxs = vxs[z_markers_idx] - vys = vys[z_markers_idx] - fcs = fcs[z_markers_idx] - ecs = ecs[z_markers_idx] - vps = np.column_stack((vxs, vys)) + if len(self._facecolor3d): + fcs = (_zalpha(self._facecolor3d, vzs) if self._depthshade else + self._facecolor3d) + fcs = mcolors.to_rgba_array(fcs, self._alpha) + fcs = fcs[z_markers_idx] + self.set_facecolors(fcs) - fcs = mcolors.to_rgba_array(fcs, self._alpha) + ecs = (_zalpha(self._edgecolor3d, vzs) if self._depthshade else + self._edgecolor3d) + ecs = ecs[z_markers_idx] ecs = mcolors.to_rgba_array(ecs, self._alpha) - self.set_edgecolors(ecs) - self.set_facecolors(fcs) + vzs = vzs[z_markers_idx] + vxs = vxs[z_markers_idx] + vys = vys[z_markers_idx] + vps = np.column_stack((vxs, vys)) PathCollection.set_offsets(self, vps) return np.min(vzs) if vzs.size else np.nan diff --git a/lib/mpl_toolkits/tests/test_mplot3d.py b/lib/mpl_toolkits/tests/test_mplot3d.py index 37532335e38d..a8d311da2b4f 100644 --- a/lib/mpl_toolkits/tests/test_mplot3d.py +++ b/lib/mpl_toolkits/tests/test_mplot3d.py @@ -232,6 +232,14 @@ def test_scatter3d(): z[-1] = 0 # Check that scatter() copies the data. +def test_scatter3d_nonfilledmarker(): + # Check that scattering a non-filled marker works + fig = plt.figure() + ax = fig.add_subplot(111, projection='3d') + ax.scatter(np.arange(10), np.arange(10), np.arange(10), marker='x') + fig.canvas.draw() + + @mpl3d_image_comparison(['scatter3d_color.png']) def test_scatter3d_color(): fig = plt.figure() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy