enthought / enthought/mayavi

Data containing NaN values

Open
#1,279 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
316
Avg merge
7h 44m
Merged PRs (30d)
5

Description

**How to display the nan values in the 3D data body as transparent or white colors when using 'volume_slice'?**
**In the below image, brown represents the area with nan value. How can I replace brown with transparent or white color?**
**Hope to receive an answer, thanks a lot!!!**
![image](https://github.com/enthought/mayavi/assets/61670822/b450e170-3b82-442a-93f0-16a47a87b35e)
**my code is as follows:**
`import numpy as np`
`from mayavi import mlab`
`pre_cwt = np.load('predicted_Zp_better.npy')`
`fig = mlab.figure(figure='PI', bgcolor=(1, 1, 1), fgcolor=(0, 0, 0))`
`pre_cwt[pre_cwt == 0] = np.nan`
`scalars = pre_cwt # specifying the data array`
`mlab.volume_slice(scalars, slice_index=0, plane_orientation='x_axes', figure=fig, colormap='jet') # Time slice`
`mlab.volume_slice(scalars, slice_index=0, plane_orientation='y_axes', figure=fig, colormap='jet') # Inline slice`
`mlab.volume_slice(scalars, slice_index=0, plane_orientation='z_axes', figure=fig, colormap='jet') # Xline slice`
`mlab.axes(xlabel='Times(ms)', ylabel='Inline', zlabel='Xline', nb_labels=1) # Add axes labels`
`mlab.colorbar()`
`mlab.outline()`
`mlab.show()`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.