volume_sharemap.py 593 B

123456789101112131415161718
  1. """Share the same color and transparency
  2. mapping across different volumes"""
  3. from vedo import Volume, show
  4. import numpy as np
  5. arr = np.zeros(shape=(50,60,70))
  6. for i in range(50):
  7. for j in range(60):
  8. for k in range(70):
  9. arr[i,j,k] = k
  10. vol1 = Volume(arr ).mode(1).cmap('jet', alpha=[0,1], vmin=0, vmax=80).add_scalarbar("vol1")
  11. vol2 = Volume(arr+30).mode(1).cmap('jet', alpha=[0,1], vmin=0, vmax=80).add_scalarbar("vol2")
  12. # or equivalently, to set transparency:
  13. # vol1.alpha([0,1], vmin=0, vmax=70)
  14. show([(vol2, __doc__), vol1], shape=(2,1), axes=1, elevation=-25)