set_background

Plotter.set_background(color, top=None, all_renderers=True)

Set the background color.

Parameters
colorstr or 3 item sequence, optional

Either a string, rgb list, or hex color string. Defaults to current theme parameters. For example:

  • color='white'

  • color='w'

  • color=[1, 1, 1]

  • color='#FFFFFF'

topstr or 3 item sequence, optional

If given, this will enable a gradient background where the color argument is at the bottom and the color given in top will be the color at the top of the renderer.

all_renderersbool

If True, applies to all renderers in subplots. If False, then only applies to the active renderer.

Examples

Set the background color to black.

>>> import pyvista
>>> plotter = pyvista.Plotter()
>>> plotter.set_background('black')
>>> plotter.background_color
(0.0, 0.0, 0.0)

Set the background color at the bottom to black and white at the top. Display a cone as well.

>>> import pyvista
>>> pl = pyvista.Plotter()
>>> actor = pl.add_mesh(pyvista.Cone())
>>> pl.set_background('black', top='white')
>>> pl.show()
../../../_images/pyvista-Plotter-set_background-1_00_00.png
../../../_images/pyvista-Plotter-set_background-1_00_01.png