Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

You can change a visualization’s appearance by accessing and modifying its transfer function.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 import example_utils
      2 from vapor import session, renderer, dataset, camera, transferfunction
      3 from vapor.utils import histogram
      4 

File ~/work/vapor-python-cookbook/vapor-python-cookbook/notebooks/example_utils.py:20
     16     sys.path.append('..')
     19 from inspect import signature
---> 20 import numpy as np
     21 from math import sin
     23 def SampleFunctionOnRegularGrid(f, ext=None, shape=None):

ModuleNotFoundError: No module named 'numpy'

Changing Opacities

Vapor’s transferFunctionWidget allows you to adjust the opacity points of a renderer as you would within Vapor’s GUI.

If you do not have access to the widget, we provide static options for changing the opacities as well. We created a volume rendering however it is fully opaque. We can use a transfer function to adjust the visible portions. Before we adjust the opacity map of the TF, we get a histogram to help us determine what we want to hide.

Usually we want to hide the most common value so below we construct an opacity map that accomplishes this.

We can get the matplotlib histogram plot and add our opacity map to it to compare.

Now we apply the map to the transfer function

You can adjust the colormap in a similar fashion. Use help(tf) for more information. Vapor includes a list of built-in colormaps and these can be applied with tf.LoadBuiltinColormap(name)

Builtin Colormaps

List of All Builtin Colormaps