Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@QuocAnhVu

Description

@QuocAnhVu
Issue body actions

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.