Skip to content

Path3DCollection.set_color(self, c) does not change the color of scatter points. #18386

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

Closed
QuocAnhVu opened this issue Sep 1, 2020 · 1 comment

Comments

@QuocAnhVu
Copy link

Bug report

Bug summary

I created a Path3DCollection from Axes.scatter(self). The Path3DCollection.set_color(self) method does not change the color of scatter points.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation

np.random.seed(1000)
BLUE = "#1f77b4"
YELLOW = "#bcbd22"

points = np.random.random_sample((1000, 3))
colors = lambda: list(YELLOW if np.random.random() > 0.5 else BLUE for _ in points)

fig = plt.figure()
ax = plt.axes(projection='3d')
paths = ax.scatter(points[:,0], points[:,1], points[:,2])
def step(i):
    paths.set_color(colors())
    # paths.set_3d_properties(points[:,2], 'z')   # Try uncommenting this line
    return paths
anim = animation.FuncAnimation(fig, step, frames=200, interval=20)
plt.show()

Actual outcome

Colors are static and do not change from initial.
no_change

If you run set_3d_properties(), then the colors do change, but I don't know how to use this function to leave the coordinates alone.
yes_change

Expected outcome
The magic of Christmas.

The points should not change in position like in the first image, but should change in color like in the second image.

Matplotlib version

  • Operating system: macOS Catalina 10.15.6
  • Matplotlib version: 3.3.1
  • Matplotlib backend: MacOSX
  • Python version: 3.8.5 (default, Jul 21 2020, 10:48:26) [Clang 11.0.3 (clang-1103.0.32.62)]

Matplotlib installed from pip

@QuLogic QuLogic self-assigned this Sep 1, 2020
@QuLogic QuLogic added this to the v3.4.0 milestone Oct 16, 2020
@QuLogic
Copy link
Member

QuLogic commented Oct 16, 2020

This was fixed by #18189.

@QuLogic QuLogic closed this as completed Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants