pyvista.opacity_transfer_function#
- opacity_transfer_function(mapping, n_colors, interpolate: bool = True, kind='quadratic')[ソース]#
Get the opacity transfer function for a mapping.
These values will map on to a scalar bar range and thus the number of colors (
n_colors
) must correspond to the number of colors in the color mapping that these opacities are associated to.If interpolating,
scipy.interpolate.interp1d
is used if available, otherwisenp.interp
is used. Thekind
argument controls the kind of interpolation forinterp1d
.This returns the opacity range from 0 to 255, where 0 is totally transparent and 255 is totally opaque.
The equation to create the sigmoid mapping is:
1 / (1 + exp(-x))
wherex
is the range from-a
to+a
anda
is the value given in themapping
string. Default isa=10
for 'sigmoid' mapping.- パラメータ:
- mapping
list
[float
] |str
The opacity mapping to use. Can be a
str
name of a predefined mapping including'linear'
,'geom'
,'sigmoid'
,'sigmoid_1-10,15,20'
, andforeground
. Append an'_r'
to any of those names (exceptforeground
) to reverse that mapping. The mapping can also be a custom user-defined array/list of values that will be interpolated across then_color
range.- n_colors
int
The number of colors that the opacities must be mapped to.
- interpolatebool
すべての色に対して不透明度のマッピングを補間するかどうかのフラグ.
- kind
str
The interpolation kind if
interpolate
isTrue
andscipy
is available. Ifscipy
is not available, linear interpolation is always used. Options are:'linear'
'nearest'
'zero'
'slinear'
'quadratic'
'cubic'
'previous'
'next'
- mapping
- 戻り値:
numpy.ndarray
Array of
numpy.uint8
valuesn_colors
long containing the [0-255] opacity mapping values.
例
>>> import pyvista as pv >>> # Fetch the `sigmoid` mapping between 0 and 255 >>> tf = pv.opacity_transfer_function('sigmoid', 256) >>> # Fetch the `geom_r` mapping between 0 and 1 >>> tf = pv.opacity_transfer_function('geom_r', 256).astype(float) / 255.0 >>> # Interpolate a user defined opacity mapping >>> opacity = [0, 0.2, 0.9, 0.6, 0.3] >>> tf = pv.opacity_transfer_function(opacity, 256)