pyvista.Plotter.set_background#
- Plotter.set_background(
- color,
- top=None,
- right=None,
- side=None,
- corner=None,
- all_renderers: bool = True,
Set the background color.
- Parameters:
- color
ColorLike
,optional
Either a string, rgb list, or hex color string. Defaults to current theme parameters. For example:
color='white'
color='w'
color=[1.0, 1.0, 1.0]
color='#FFFFFF'
- top
ColorLike
,optional
If given, this will enable a gradient background where the
color
argument is at the bottom and the color given intop
will be the color at the top of the renderer.- right
ColorLike
,optional
If given, this will enable a gradient background where the
color
argument is at the left and the color given inright
will be the color at the right of the renderer.- side
ColorLike
,optional
If given, this will enable a gradient background where the
color
argument is at the center and the color given inside
will be the color at the side of the renderer.- corner
ColorLike
,optional
If given, this will enable a gradient background where the
color
argument is at the center and the color given incorner
will be the color at the corner of the renderer.- all_renderersbool, default:
True
If
True
, applies to all renderers in subplots. IfFalse
, then only applies to the active renderer.
- color
Examples
Set the background color to black.
>>> import pyvista as pv >>> plotter = pv.Plotter() >>> plotter.set_background('black') >>> plotter.background_color Color(name='black', hex='#000000ff', opacity=255) >>> plotter.close()
Set the background color at the bottom to black and white at the top. Display a cone as well.
>>> import pyvista as pv >>> pl = pv.Plotter() >>> actor = pl.add_mesh(pv.Cone()) >>> pl.set_background('black', top='white') >>> pl.show()