plot#
- StructuredGrid.plot(off_screen=None, full_screen=None, screenshot=None, interactive=True, cpos=None, window_size=None, show_bounds=False, show_axes=None, notebook=None, background=None, text='', return_img=False, eye_dome_lighting=False, volume=False, parallel_projection=False, use_ipyvtk=None, jupyter_backend=None, return_viewer=False, return_cpos=False, jupyter_kwargs=None, theme=None, hidden_line_removal=None, anti_aliasing=None, zoom=None, **kwargs)#
Plot a vtk or numpy object.
- Parameters
- var_item
pyvista.DataSet
,vtk
,or
numpy
object
VTK object or
numpy
array to be plotted.- off_screenbool,
optional
Plots off screen when
True
. Helpful for saving screenshots without a window popping up. Defaults to the global settingpyvista.OFF_SCREEN
.- full_screenbool,
optional
Opens window in full screen. When enabled, ignores
window_size
. Defaults to active theme setting inpyvista.global_theme.full_screen
.- screenshot
str
or bool,optional
Saves screenshot to file when enabled. See:
Plotter.screenshot()
. DefaultFalse
.When
True
, takes screenshot and returnsnumpy
array of image.- interactivebool,
optional
Allows user to pan and move figure. Defaults to
pyvista.global_theme.interactive
.- cpos
list
,optional
List of camera position, focal point, and view up.
- window_size
list
,optional
Window size in pixels. Defaults to global theme
pyvista.global_theme.window_size
.- show_boundsbool,
optional
Shows mesh bounds when
True
. DefaultFalse
.- show_axesbool,
optional
Shows a vtk axes widget. If
None
, enabled according topyvista.global_theme.axes.show
.- notebookbool,
optional
When
True
, the resulting plot is placed inline a jupyter notebook. Assumes a jupyter console is active.- background
color_like
,optional
Color of the background.
- text
str
,optional
Adds text at the bottom of the plot.
- return_imgbool,
optional
Returns numpy array of the last image rendered.
- eye_dome_lightingbool,
optional
Enables eye dome lighting.
- volumebool,
optional
Use the
Plotter.add_volume()
method for volume rendering.- parallel_projectionbool,
optional
Enable parallel projection.
- use_ipyvtkbool,
optional
Deprecated. Instead, set the backend either globally with
pyvista.set_jupyter_backend('ipyvtklink')
or withbackend='ipyvtklink'
.- jupyter_backend
str
,optional
Jupyter notebook plotting backend to use. One of the following:
'none'
: Do not display in the notebook.'static'
: Display a static figure.'ipygany'
: Show aipygany
widget'panel'
: Show apanel
widget.
This can also be set globally with
pyvista.set_jupyter_backend()
.- return_viewerbool,
optional
Return the jupyterlab viewer, scene, or display object when plotting with jupyter notebook.
- return_cposbool,
optional
Return the last camera position from the render window when enabled. Defaults to value in theme settings.
- jupyter_kwargs
dict
,optional
Keyword arguments for the Jupyter notebook plotting backend.
- theme
pyvista.themes.DefaultTheme
,optional
Plot-specific theme.
- hidden_line_removalbool,
optional
Wireframe geometry will be drawn using hidden line removal if the rendering engine supports it. See
Plotter.enable_hidden_line_removal
. Defaults to the theme settingpyvista.global_theme.hidden_line_removal
.- anti_aliasingbool,
optional
Enable or disable anti-aliasing. Defaults to the theme setting
pyvista.global_theme.antialiasing
.- zoom
float
,optional
Camera zoom. A value greater than 1 is a zoom-in, a value less than 1 is a zoom-out. Must be greater than 0.
- **kwargs
optional
keyword
arguments
See
pyvista.Plotter.add_mesh()
for additional options.
- var_item
- Returns
- cpos
list
List of camera position, focal point, and view up. Returned only when
return_cpos=True
or set in the default global or plot theme. Not returned when in a jupyter notebook andreturn_viewer=True
.- image
np.ndarray
Numpy array of the last image when either
return_img=True
orscreenshot=True
is set. Not returned when in a jupyter notebook withreturn_viewer=True
. Optionally contains alpha values. Sized:[Window height x Window width x 3] if the theme sets
transparent_background=False
.[Window height x Window width x 4] if the theme sets
transparent_background=True
.
widget
IPython widget when
return_viewer=True
.
- cpos
Examples
Plot a simple sphere while showing its edges.
>>> import pyvista >>> mesh = pyvista.Sphere() >>> mesh.plot(show_edges=True)