moxel.visualize
This module provides helper functions for visualizing voxels.
Tip
For faster rendering you should prefer plot_voxels_pv().
- moxel.visualize.plot_voxels_mpl(voxels, *, fill_pattern=None, colorbar=True, cmap='viridis', **kwargs)[source]
Visualize voxels with Axes3d.voxels.
- Parameters:
voxels (3D array)
fill_pattern (3D array of bool, optional) – A 3D array of truthy values, indicating which voxels to fill. If not specified, all voxels are filled.
colorbar (bool, default=True) – Whether to include a colorbar.
cmap (str, default='viridis') – Colormap that colorizes the voxels based on their value.
**kwargs –
Valid keyword arguments for Axes3d.voxels.
Note
Do not pass the argument
facecolorsof Axes3d.voxels. This argument is used under the hood byplot_voxels()to generate the colors of the voxels based on the specifiedcmap.
- Returns:
fig
- Return type:
Examples
>>> voxels = np.random.randn(5, 5, 5) >>> fig = plot_voxels_mpl(voxels, cmap='coolwarm') >>> plt.show() # Not needed for Jupyter.
- moxel.visualize.plot_voxels_pv(voxels, **kwargs)[source]
Visualize voxels with Plotter.add_volume
Note
For interactive plots in Jupyter:
pip install "pyvista[jupyter]"- Parameters:
voxels (3D array)
**kwargs (dict, optional) – Valid keyword arguments for Plotter.add_volume.
Examples
>>> voxels = np.random.randn(5, 5, 5) >>> plot_voxels_pv(voxels, cmap='coolwarm')