From 81b5241c7b91e0d9bc667b8c5f55966888672a70 Mon Sep 17 00:00:00 2001 From: Robert Johansson Date: Fri, 2 May 2014 15:37:38 +0900 Subject: [PATCH 1/2] avoid np.nan values in colors array returned by axes3d._shade_colors --- lib/mpl_toolkits/mplot3d/axes3d.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 22db1f5c6436..e083eb7f1537 100755 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -1675,8 +1675,10 @@ def _shade_colors(self, color, normals): ''' shade = np.array([np.dot(n / proj3d.mod(n), [-1, -1, 0.5]) + if proj3d.mod(n) else np.nan for n in normals]) mask = ~np.isnan(shade) + shade[~mask] = 0 if len(shade[mask]) > 0: norm = Normalize(min(shade[mask]), max(shade[mask])) From 1d8c18b8eb0d8d74b569dec13fab074bfb51c459 Mon Sep 17 00:00:00 2001 From: Robert Johansson Date: Tue, 6 May 2014 00:20:42 +0900 Subject: [PATCH 2/2] make sure fill values for shade array are within the correct range --- lib/mpl_toolkits/mplot3d/axes3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index e083eb7f1537..35edc5501282 100755 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -1678,10 +1678,10 @@ def _shade_colors(self, color, normals): if proj3d.mod(n) else np.nan for n in normals]) mask = ~np.isnan(shade) - shade[~mask] = 0 if len(shade[mask]) > 0: norm = Normalize(min(shade[mask]), max(shade[mask])) + shade[~mask] = min(shade[mask]) color = colorConverter.to_rgba_array(color) # shape of color should be (M, 4) (where M is number of faces) # shape of shade should be (M,)