Skip to content

Commit 6b68d86

Browse files
authored
Merge pull request #13235 from anntzer/vectorize-zalpha
Vectorize mplot3d.art3d.zalpha.
2 parents 121102b + 3f59cde commit 6b68d86

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

+6-6
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)