8000 Vectorize mplot3d.art3d.zalpha. · matplotlib/matplotlib@3f59cde · GitHub
[go: up one dir, main page]

Skip to content

Commit 3f59cde

Browse files
committed
Vectorize mplot3d.art3d.zalpha.
I intentionally did not deprecate the now unused get_colors, as there's already another PR doing that.
1 parent e9b8d3f commit 3f59cde

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -790,9 +790,9 @@ def zalpha(colors, zs):
790790
# in all three dimensions. Otherwise, at certain orientations,
791791
# the min and max zs are very close together.
792792
# Should really normalize against the viewing depth.
793-
colors = get_colors(colors, len(zs))
794-
if len(zs):
795-
norm = Normalize(min(zs), max(zs))
796-
sats = 1 - norm(zs) * 0.7
797-
colors = [(c[0], c[1], c[2], c[3] * s) for c, s in zip(colors, sats)]
798-
return colors
793+
if len(zs) == 0:
794+
return np.zeros((0, 4))
795+
norm = Normalize(min(zs), max(zs))
796+
sats = 1 - norm(zs) * 0.7
797+
rgba = np.broadcast_to(mcolors.to_rgba_array(colors), (len(zs), 4))
798+
return np.column_stack([rgba[:, :3], rgba[:, 3] * sats])

0 commit comments

Comments
 (0)
0