Skip to content

Note

Click here to download the full example code or to run this example in your browser via Binder

Example with the pyvista 3d plotting library

Mkdocs-Gallery supports examples made with the pyvista library.

In order to use pyvista, the conf_script of the project should include the following lines to adequatly configure pyvista:

import pyvista

pyvista.BUILDING_GALLERY = True
pyvista.OFF_SCREEN = True

conf = {
    ...,
    "image_scrapers": ("pyvista", ...),
}
import pyvista as pv

You can display an animation as a gif

sphere = pv.Sphere()
pl = pv.Plotter()
pl.enable_hidden_line_removal()
pl.add_mesh(sphere, show_edges=True, color="tan")
# for this example
pl.open_gif("animation.gif", fps=10)
# alternatively, to disable movie generation:
# pl.show(auto_close=False, interactive=False)
delta_x = 0.05
center = sphere.center
for angle in range(0, 360, 10):

    rot = sphere.rotate_x(angle, point=(0, 0, 0), inplace=False)

    pl.clear_actors()
    pl.add_mesh(rot, show_edges=True, color="tan")
    pl.write_frame()


pl.show()

plot 11 pyvista

or simply show a static plot

sphere = pv.Sphere()
pl = pv.Plotter()
pl.add_mesh(sphere, show_edges=True, color="tan")
pl.show()

plot 11 pyvista

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

Launch binder

Download Python source code: plot_11_pyvista.py

Download Jupyter notebook: plot_11_pyvista.ipynb

Gallery generated by mkdocs-gallery