Skip to content

Backport PR #26834 on branch v3.8.x (Fix Issue 26821: [Bug]: ValueError: The truth value... when an ndarray is passed to the color kwarg of axes3d.scatter) #26836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
xs, ys, zs, s, c, color = cbook.delete_masked_points(
xs, ys, zs, s, c, kwargs.get('color', None)
)
if kwargs.get('color', None):
if kwargs.get("color") is not None:
kwargs['color'] = color

# For xs and ys, 2D scatter() will do the copying.
Expand Down
9 changes: 9 additions & 0 deletions lib/mpl_toolkits/mplot3d/tests/test_axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2270,3 +2270,12 @@ def test_Poly3DCollection_init_value_error():
'or both for shade to work.'):
poly = np.array([[0, 0, 1], [0, 1, 1], [0, 0, 0]], float)
c = art3d.Poly3DCollection([poly], shade=True)


def test_ndarray_color_kwargs_value_error():
# smoke test
# ensures ndarray can be passed to color in kwargs for 3d projection plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(1, 0, 0, color=np.array([0, 0, 0, 1]))
fig.canvas.draw()