Debian Codegraph @

examples/02-plot/orbit.py

raw
1 """
2 .. _orbit_example:
3
4 Orbiting
5 ~~~~~~~~
6
7 Orbit around a scene.
8
9 .. note::
10 The quality of the movie will be better when using
11 ``pl.open_movie('orbit.mp4')`` instead of
12 ``pl.open_gif('orbit.gif')``
13
14 For orbiting to work you first have to show the scene and leave the plotter open
15 with ``.show(auto_close=False)``. You may also have to set
16 ``pv.Plotter(off_screen=True)``
17
18 .. note::
19 Use ``lighting=False`` to reduce the size of the color space to avoid
20 "jittery" GIFs when showing the scalar bar.
21
22 """
23
24 # sphinx_gallery_thumbnail_number = 2
25 import pyvista as pv
26 from pyvista import examples
27
28 mesh = examples.download_st_helens().warp_by_scalar()
29
30 # %%
31 # Orbit around the Mt. St Helens dataset using
32 # :func:`~pyvista.Plotter.generate_orbital_path`.
33
34 pl = pv.Plotter()
35 pl.add_mesh(mesh, lighting=False)
36 pl.camera.zoom(1.5)
37 pl.show(auto_close=False)
38 path = pl.generate_orbital_path(n_points=20, shift=mesh.length)
39 pl.open_gif('orbit.gif')
40 pl.orbit_on_path(path, write_frames=True)
41 pl.close()
42
43
44 # %%
45
46 pl = pv.Plotter()
47 pl.add_mesh(mesh, lighting=False)
48 pl.show_grid()
49 pl.show(auto_close=False)
50 viewup = [0.5, 0.5, 1]
51 path = pl.generate_orbital_path(factor=2.0, shift=10000, viewup=viewup, n_points=20)
52 pl.open_gif('orbit.gif')
53 pl.orbit_on_path(path, write_frames=True, viewup=[0, 0, 1], step=0.05)
54 pl.close()
55
56
57 # %%
58
59 mesh = examples.download_dragon()
60 viewup = [0, 1, 0]
61
62 # %%
63 pl = pv.Plotter()
64 pl.add_mesh(mesh)
65 pl.show(auto_close=False)
66 path = pl.generate_orbital_path(factor=2.0, n_points=20, viewup=viewup, shift=0.2)
67 pl.open_gif('orbit.gif')
68 pl.orbit_on_path(path, write_frames=True, viewup=viewup, step=0.05)
69 pl.close()
70 # %%
71 # .. tags:: plot