Skip to content

Commit

Permalink
Merge pull request matplotlib#26836 from meeseeksmachine/auto-backpor…
Browse files Browse the repository at this point in the history
…t-of-pr-26834-on-v3.8.x

Backport PR matplotlib#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)
  • Loading branch information
QuLogic authored Sep 20, 2023
2 parents b4077ef + 5619fd9 commit 325aa89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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()

0 comments on commit 325aa89

Please sign in to comment.