I have a 3D scatter plot in matplotlib plotted as ax.scatter(xyz[:, 0], xyz[:, 1], xyz[:, 2], c=xyz_rgb)
. Let's say I have two lists of indices, mask_1
and mask_2
such that these are a subset of points in xyz
. I want to be able to plot all of xyz
, then use a keyboard press to toggle between xyz[:,:]
, xyz[mask_1,:]
and xyz[mask_2,:]
. Is this doable? If so, how would I achieve that? The problematic part isn't capturing the keyboard events, but actually toggling the visibility of points in a plot.
Asked
Active
Viewed 161 times
0

Hal T
- 527
- 7
- 22
-
I would have guessed the problematic part is the key capture if anything. Visibility can be done via `set_visible(False)` (or `True`). – ImportanceOfBeingErnest Aug 13 '18 at 18:29
-
I'm not interested in drawing 3 separate figures and hiding them based on input. I want to have one figure in which points are toggled. So that the camera perspective, etc. is preserved. – Hal T Aug 13 '18 at 18:31
-
if you have 3 plots `points1`, `points2`, `points3`, you can do `plot1.set_visible(False)` to hide points1. Alternatively you can work with a single `points1` and update its data. – ImportanceOfBeingErnest Aug 13 '18 at 18:33
-
The 3 plot one won't work for the reason I stated. How do I go about updating the data of an existing plot? – Hal T Aug 13 '18 at 18:37
-
Both will work. For updating a scatter see [this question](https://stackoverflow.com/questions/42722691/python-matplotlib-update-scatter-plot-from-a-function). – ImportanceOfBeingErnest Aug 13 '18 at 18:44