Volume rendering of toy data#

Volume rendering of toy trig data

image volume toy data
/opt/hostedtoolcache/Python/3.12.14/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:400: RuntimeWarning: divide by zero encountered in divide
  screen_full = (ndc_full[:, :2] / ndc_full[:, 3:4]) * half_canvas_size
/opt/hostedtoolcache/Python/3.12.14/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:400: RuntimeWarning: invalid value encountered in divide
  screen_full = (ndc_full[:, :2] / ndc_full[:, 3:4]) * half_canvas_size
/opt/hostedtoolcache/Python/3.12.14/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:412: RuntimeWarning: invalid value encountered in divide
  screen_sel = (ndc_sel[:, :2] / ndc_sel[:, 3:4]) * half_canvas_size

# test_example = false

import fastplotlib as fpl
import numpy as np

n_cols = 100
n_rows = 100
z = 50

xs = np.linspace(0, 1_000, n_cols)

sine = np.sin(np.sqrt(xs))

data = np.dstack([np.vstack([sine * i for i in range(n_rows)]).astype(np.float32) * j for j in range(z)])

figure = fpl.Figure(cameras="3d", controller_types="orbit", size=(700, 560))

volume = figure[0, 0].add_image_volume(data)

figure.show()

# NOTE: fpl.loop.run() should not be used for interactive sessions
# See the "JupyterLab and IPython" section in the user guide
if __name__ == "__main__":
    print(__doc__)
    fpl.loop.run()

Total running time of the script: (0 minutes 0.454 seconds)

Gallery generated by Sphinx-Gallery