.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plotting/volume_plot.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plotting_volume_plot.py: Multi-view Volume Plot ====================== Plot various views of a structural MRI. .. GENERATED FROM PYTHON SOURCE LINES 11-41 .. image-sg:: /gallery/plotting/images/sphx_glr_volume_plot_001.png :alt: volume plot :srcset: /gallery/plotting/images/sphx_glr_volume_plot_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np from vispy import io, plot as vp fig = vp.Fig(bgcolor='k', size=(800, 800), show=False) vol_data = np.load(io.load_data_file('brain/mri.npz'))['data'] vol_data = np.flipud(np.rollaxis(vol_data, 1)) vol_data = vol_data.astype(np.float32) clim = [32, 192] texture_format = "auto" # None for CPUScaled, "auto" for GPUScaled vol_pw = fig[0, 0] v = vol_pw.volume(vol_data, clim=clim, texture_format=texture_format) vol_pw.view.camera.elevation = 30 vol_pw.view.camera.azimuth = 30 vol_pw.view.camera.scale_factor /= 1.5 shape = vol_data.shape fig[1, 0].image(vol_data[:, :, shape[2] // 2], cmap='grays', clim=clim, fg_color=(0.5, 0.5, 0.5, 1), texture_format=texture_format) fig[0, 1].image(vol_data[:, shape[1] // 2, :], cmap='grays', clim=clim, fg_color=(0.5, 0.5, 0.5, 1), texture_format=texture_format) fig[1, 1].image(vol_data[shape[0] // 2, :, :].T, cmap='grays', clim=clim, fg_color=(0.5, 0.5, 0.5, 1), texture_format=texture_format) if __name__ == '__main__': fig.show(run=True) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.399 seconds) .. _sphx_glr_download_gallery_plotting_volume_plot.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: volume_plot.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: volume_plot.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_