Closed
Closed
Copy link
Description
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.
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.
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