Change the Theme

PyVista has a few coloring themes for you to choose!

import pyvista as pv
from pyvista import examples

Define a simple plotting routine for comparing the themes

mesh = examples.download_st_helens().warp_by_scalar()


def plot_example():
    p = pv.Plotter()
    p.add_mesh(mesh)
    p.add_bounding_box()
    return p.show()

PyVista’s default color theme is chosen to be generally easy on your eyes and is best used when working long hours on your visualization project. The grey background and warm colormaps are chosen to make sure 3D renderings do not drastically change the brightness of your screen when working in dark environments.

Here’s an example of our default plotting theme - this is what you would see by default after running any of our examnples.

pv.set_plot_theme("default")

plot_example()
../../_images/sphx_glr_themes_001.png

Out:

[(581977.3046422418, 5134123.804642241, 21436.804642241805), (562835.0, 5114981.5, 2294.5), (0.0, 0.0, 1.0)]

PyVista also ships with a few plotting themes:

  • 'ParaView': this is designed to mimic ParaView’s default plotting theme

  • 'night': this is designed to be night-mode friendly with dark backgrounds and color schemes

  • 'document': this is built for use in document style plotting and making publication quality figures

Demo the 'ParaView' theme

pv.set_plot_theme("ParaView")

plot_example()
../../_images/sphx_glr_themes_002.png

Out:

[(581977.3046422418, 5134123.804642241, 21436.804642241805), (562835.0, 5114981.5, 2294.5), (0.0, 0.0, 1.0)]

Demo the 'night' theme

pv.set_plot_theme("night")

plot_example()
../../_images/sphx_glr_themes_003.png

Out:

[(581977.3046422418, 5134123.804642241, 21436.804642241805), (562835.0, 5114981.5, 2294.5), (0.0, 0.0, 1.0)]

Demo the 'document' theme

pv.set_plot_theme("document")

plot_example()
../../_images/sphx_glr_themes_004.png

Out:

[(581977.3046422418, 5134123.804642241, 21436.804642241805), (562835.0, 5114981.5, 2294.5), (0.0, 0.0, 1.0)]

Note that you can also use color gradients for the background of the plotting window!

plotter = pv.Plotter()
plotter.add_mesh(mesh)
plotter.show_grid()
# Here we set the gradient
plotter.set_background("royalblue", top="aliceblue")
plotter.show()
../../_images/sphx_glr_themes_005.png

Out:

[(581977.3046422418, 5134123.804642241, 21436.804642241805), (562835.0, 5114981.5, 2294.5), (0.0, 0.0, 1.0)]

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

Gallery generated by Sphinx-Gallery