-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opacity based on cell-volume data #482
Comments
@TBody No worries! This seems to be a common question. I'll reiterate my answer from volumetric rendering for volumetric data #472 . TLDR: To set the opacity for everything to a constant values, you need to make opacity = np.ones((256,)) * 0.5
transfer_func = {
'linear': np.linspace(0, 255, n_colors, dtype=np.uint8),
'geom': np.geomspace(1e-6, 255, n_colors, dtype=np.uint8),
'geom_r': np.geomspace(255, 1e-6, n_colors, dtype=np.uint8),
'sigmoid': sigmoid(np.linspace(-10.,10., n_colors)),
'sigmoid_3': sigmoid(np.linspace(-3.,3., n_colors)),
'sigmoid_4': sigmoid(np.linspace(-4.,4., n_colors)),
'sigmoid_5': sigmoid(np.linspace(-5.,5., n_colors)),
'sigmoid_6': sigmoid(np.linspace(-6.,6., n_colors)),
'sigmoid_7': sigmoid(np.linspace(-7.,7., n_colors)),
'sigmoid_8': sigmoid(np.linspace(-8.,8., n_colors)),
'sigmoid_9': sigmoid(np.linspace(-9.,9., n_colors)),
'sigmoid_10': sigmoid(np.linspace(-10.,10., n_colors)),
}
@MatthewFlamm @akaszynski This would be another great thing to add to our documentation! The volume rendering section could use some TLC. |
@TBody If this answers your question, please kindly let me know so we can close the issue. No rush! |
@adamgranthendry, you're correct, we need to add that. Right now I've got three PRs in the oven. Would you mind submitting one for this? It's a great example. |
@akaszynski You bet! I know I still owe you some more feedback on one of the other ones too. |
@adamgranthendry Thanks! Reading more into it, I think what I was actually trying to do was volume rendering: i.e. set the cell volumes as semi-transparent, rather than cell-surface rendering. If I set, for instance If I try P.S. I found that the opacity range has to be [0, 255] rather than [0, 1] (using |
@TBody Oh yes, you're right, my mistake. The docstring clearly states opacity is on the scale of From what I can see though, your opacity has changed. It has increased for your lower values and decreased for your higher ones. Previously, you were using Do you see how in the first instance, the left end of the color bar is clear and the right end is very intense, but how in the second instance the color is flat all throughout? Maybe we can figure out how to correctly set the opacity for you so you can see what you're trying to see. What is it exactly that you would like to do? |
Setting opacity based on cell-volume data
PyVista newbie, sorry! I'm trying to visualize some 3D data on an unstructured grid (a collection of connected 2D hexahedra, non-overlapping). The dataset is somewhat peculiar in that it has high resolution in 2 dimensions, but low resolution in the other dimension, and so the hexahedra have a small width and breadth, but a very large length (~1000x the other dimensions).
I'd like to set the opacity of the cell based on its value, and so I've tried
I find a similar behavior in Paraview with "Opacity for surfaces", so I believe that this is me not understanding VTK rather than an issue in PyVista. However, I'm not sure how to go about how to get the desired behavior, any pointers greatly appreciated!
Example Data
simple.vtk.zip
The text was updated successfully, but these errors were encountered: