Passing vmin and vmax to colormaps for Volume objects
See original GitHub issueHi @marcomusy,
It’s entirely possible that there’s a good way to do this that I’m unaware of - apologies if so.
I’m creating a couple of separate renderings of Volume objects that have scalar values at each point, and coloring those based on those scalar values with a colormap. Each rendering also has a ScalarBar associated with it. I’d like to be able to manually set the vmin and vmax on those volumes and ScalarBars, so that the top and bottom of the color range is consistent across renderings. It seems like this is supported for Mesh objects using pointColors(), but I haven’t found anything similar for Volume objects.
So far the best way I’ve found to do this is to pass a list of tuples to the Volume constructor built from the colormap I want - this gets me a consistent colormap, but the colorbar is not consistent - I’d like all the colorbars to start with the vmin and end with the vmax.
My current approach is something like this:
import vedo
import numpy as np
arr = np.zeros(shape=(100,100,100))
for ii in range(100):
for jj in range(100):
for kk in range(100):
arr[ii,jj,kk] = (((ii-50)**2 + (jj-50)**2 + (kk-50)**2 )**0.5/2)
scalarvals = list(range(0,87))
colorvals = [vedo.colorMap(x, 'turbo', vmin=min(scalarvals), vmax=max(scalarvals)) for x in scalarvals]
mapper = list(zip(scalarvals, colorvals))
vol = vedo.Volume(arr, c=mapper).mode(1).addScalarBar(c='black', size=(100,400), nlabels=2, pos=(0.05,.15), titleFontSize=35)
vedo.show(vol)
I’d much rather just pass a lambda that uses vedo.colorMap() with vmin and vmax arguments to the Volume constructor.
Thank you!
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Fantastic, works with my example on my end!
just remove
.useBounds()