Skip to content

fix: inherit color from source artist - #606

Open
jokasimr wants to merge 6 commits into
mainfrom
fix-384
Open

fix: inherit color from source artist#606
jokasimr wants to merge 6 commits into
mainfrom
fix-384

Conversation

@jokasimr

Copy link
Copy Markdown
Contributor

Fixes #384

@jokasimr
jokasimr requested a review from nvaytet August 14, 2026 14:24
@jokasimr
jokasimr marked this pull request as draft August 14, 2026 14:31
@jokasimr
jokasimr removed the request for review from nvaytet August 17, 2026 11:17
@@ -212,6 +206,10 @@ def color(self) -> np.ndarray:
def color(self, val: np.ndarray):
self.geometry.attributes['color'].array = val

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful if we can fix something else here also. Currently, if you make a scatter

f = pp.scatter3d(da, pos='position', color='black', size=2)
artist, = f.view.artists.values()

if you try to update the color of the artist with

artist.color = 'red'

it fails, because the setter expects a numpy array with the correct size.

Can we support the above by doing more work here depending on input type/shape?
If it's a string or a tuple or a 1d numpy array (of length 3 or 4), then broadcast to the full array using self._make_colors, and just set the array otherwise?

self._color should then probably be updated in the setter also.

We could then maybe add an accessor to the self._color like single_color or html_color which would be None if a colormapper is in use (html_color is probably not great because we store it as a rgb, and rgb_color could be confusing because the current .color also returns rgb colors, just a large array of them).

Below in clip3d.py, we could then just have something like

self._view.artists[node.id].color = self._view.artists[source_id].single_color

self._nodes.clear()

self.update_state()
if self._view.colormapper is None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it have to be done every time we update the controls or only when a cut is added? Meaning: can we avoid doing this also when a cut is removed?

Edit: looking more at the logic, I think this has to be called here.
Say we had 2 cuts: one in X and another in Y.
When we remove the Y cut, we are basically removing the old additional scatter that contained both X and Y selections, to now only have the selection for X. We are adding this new scatter and the colors need to be synced also.

@jokasimr
jokasimr marked this pull request as ready for review September 3, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Colors of clippings in 3d scatter plots do not match original colors

2 participants