set_background

Renderer.set_background(color, top=None)

Set the background color of this renderer.

Parameters
colorstr or 3 item list, optional

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

  • color='white'

  • color='w'

  • color=[1, 1, 1]

  • color='#FFFFFF'

topstr or 3 item list, 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.

Examples

Set the background color to black with a gradient to white at the top of the plot.

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