RGBA color support inside a Jupyter Notebook #2642
Replies: 0 comments 5 replies
-
Now that I think about it, maybe this could be fixed by #258 ? Well, it's also possible that my code snippet isn't correct. |
Beta Was this translation helpful? Give feedback.
-
It's not your code, it's At the moment, we are using Perhaps #258 would be a better approach and more worth our time. K3D seems far more robust than VTKjs so maybe we should focus on creating a way to display PyVista scenes with K3D rather than fixing the VTKjs script. |
Beta Was this translation helpful? Give feedback.
-
Also, I've found a hack of a fix. If you only have a single array present in the dataset you'd like to send to VTKjs, it'll work: import pyvista as pv
import numpy as np
sphere = pv.Sphere()
scalars = np.ones((sphere.GetNumberOfPoints(), 4)) * 255.0
scalars = scalars.astype('ubyte')
# ONLY have one array present for VTKjs
# del sphere.point_arrays['Normals']
sphere.clear_arrays()
p = pv.Plotter()
p.add_mesh(sphere, rgba=True, scalars=scalars)
p.show() |
Beta Was this translation helpful? Give feedback.
-
This hack is already amazing as a short-term solution, thank you so much! I will try it. So out of curiosity, is it the array of And the choice between K3D and VTKjs looks like a dilemma. Even if I looked their showcase gallery, I still need to try K3D myself to have a better understanding of its capabilities. |
Beta Was this translation helpful? Give feedback.
-
The VTKjs export script has trouble choosing the active array. It always grabs the array at the 0th index so if you remove all other arrays other than what you want to plot it should work fine.
I definitely need to look into it more as well |
Beta Was this translation helpful? Give feedback.
-
When I use RGBA colors inside a Jupyter Notebook, I obtain an unexpected result:
When I run this script natively, I get the right result of course:
Beta Was this translation helpful? Give feedback.
All reactions