DataSet.plot#
- DataSet.plot(
- off_screen: bool | None = None,
- full_screen: bool | None = None,
- screenshot: str | bool | None = None,
- interactive: bool = True,
- cpos: CameraPositionOptions | None = None,
- window_size: list[int] | None = None,
- show_bounds: bool = False,
- show_axes: bool | None = None,
- notebook: bool | None = None,
- background: ColorLike | None = None,
- text: str = '',
- return_img: bool = False,
- eye_dome_lighting: bool = False,
- volume: bool = False,
- parallel_projection: bool = False,
- jupyter_backend: JupyterBackendOptions | None = None,
- return_viewer: bool = False,
- return_cpos: bool = False,
- jupyter_kwargs: dict[str, Any] | None = None,
- theme: Theme | ThemeOptions | str | None = None,
- anti_aliasing: Literal['ssaa', 'msaa', 'fxaa'] | bool | None = None,
- zoom: str | float | None = None,
- border: bool | None = None,
- border_color: ColorLike | None = None,
- border_width: float | None = None,
- ssao: bool = False,
- before_close_callback: Callable[[Plotter], None] | None = None,
- **kwargs,
Plot a PyVista, NumPy, or VTK object.
Note
This function is also available via command-line interface. See pyvista plot for details.
- Parameters:
- var_item
pyvista.DataSet See
Plotter.add_meshfor all supported types.- 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, default:
pyvista.plotting.themes.Theme.full_screen Opens window in full screen. When enabled, ignores
window_size.- screenshot
str| bool,optional Saves screenshot to file when enabled. See:
Plotter.screenshot(). DefaultFalse.When
True, takes screenshot and returnsnumpyarray of image.- interactivebool, default:
pyvista.plotting.themes.Theme.interactive Allows user to pan and move figure.
- cpos
CameraPositionOptions,optional List of camera position, focal point, and view up. See the
pyvista.Plotter.camera_positionfor concrete examples on how to use this parameter and Cameras for a detailed documentation onpyvista.Camera.- window_size
list[int], default:pyvista.plotting.themes.Theme.window_size Window size in pixels.
- show_boundsbool, default:
False Shows mesh bounds when
True.- show_axesbool, default:
pyvista.plotting.themes._AxesConfig.show Shows a vtk axes widget.
- notebookbool, default:
pyvista.plotting.themes.Theme.notebook When
True, the resulting plot is placed inline a jupyter notebook. Assumes a jupyter console is active.- background
ColorLike, default:pyvista.plotting.themes.Theme.background Color of the background.
- text
str,optional Adds text at the bottom of the plot.
- return_imgbool, default:
False Returns a NumPy array of the last image rendered.
- eye_dome_lightingbool,
optional Enables eye dome lighting.
- volumebool, default:
False Use the
Plotter.add_volume()method for volume rendering.- parallel_projectionbool, default:
False Enable parallel projection.
- jupyter_backend
JupyterBackendOptions,optional Jupyter notebook plotting backend to use. See available documentation at
pyvista.set_jupyter_backend()to see all valid values for this parameter along with a detailed documentation.Defaults to
pyvista.plotting.themes.Theme.jupyter_backend- return_viewerbool, default:
False Return the jupyterlab viewer, scene, or display object when plotting with jupyter notebook.
- return_cposbool, default:
False 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. See Customize Trame Toolbar for an example using this keyword.
- theme
pyvista.plotting.themes.Theme|str,optional Plot-specific theme. Accepts a
Themeinstance or a registered theme name (for example,'dark'); seeregistered_themes().- anti_aliasing
Literal[‘ssaa’, ‘msaa’, ‘fxaa’] | bool,optional Enable or disable anti-aliasing. If
True, uses"msaa". If False, disablesanti_aliasing. If a string, should be one of the following:"ssaa"- Super-Sample Anti-Aliasing"msaa"- Multi-Sample Anti-Aliasing"fxaa"- Fast Approximate Anti-Aliasing
Defaults to
pyvista.plotting.themes.Theme.anti_aliasing- zoom
float|str,optional Camera zoom. Either
'tight'or a float. A value greater than 1 is a zoom-in, a value less than 1 is a zoom-out. Must be greater than 0.- borderbool,
optional Draw a border around the render window. None is drawn by default.
- border_color
ColorLike,optional Color of the border. Defaults to
pyvista.global_theme.border_color. Accepts a string, rgb list, or hex color string. For example:color='white'color='w'color=[1.0, 1.0, 1.0]color='#FFFFFF'
- border_width
float,optional Width of the border in pixels when enabled. Defaults to
pyvista.global_theme.border_width.- ssaobool,
optional Enable surface space ambient occlusion (SSAO). See
Plotter.enable_ssao()for more details.- before_close_callback
Callable,optional Callback that is called before the plotter is closed. The function takes a single parameter, which is the plotter object before it closes. An example of use is to capture a screenshot after interaction:
def fun(plotter): plotter.screenshot('file.png')
- **kwargs
dict,optional 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=Trueor 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=Trueorscreenshot=Trueis 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
ipywidgets.Widget IPython widget when
return_viewer=True.
- cpos
Examples#
Download Python source code | Download Jupyter notebook
Plot a simple sphere while showing its edges.
Plot a volume mesh. Color by distance from the center of the
ImageData. Note volume=True is passed.
>>> import numpy as np
>>> grid = pv.ImageData(dimensions=(32, 32, 32), spacing=(0.5, 0.5, 0.5))
>>> grid['data'] = np.linalg.norm(grid.center - grid.points, axis=1)
>>> grid['data'] = np.abs(grid['data'] - grid['data'].max()) ** 3
>>> grid.plot(volume=True)
See Also#
Used In#
Guides
- Overview (6 uses)
- Plotting Themes (3 uses)
- PyVista Data Model (3 uses)
- What Is a Mesh? (3 uses)
- Examples & Datasets (2 uses)
8 more
- Transitioning From VTK to PyVista (2 uses)
- Why PyVista? (2 uses)
- Basic API Usage (1 use)
- Interactive Plotting (1 use)
- Sphinx PyVista Plot Directive (1 use)
- User Guide (1 use)
- downloads (1 use)
- examples (1 use)
Docstring Examples
ImageDataFilters.image_dilate_erode(3 uses)Plotter.add_mesh(3 uses)PolyDataFilters.delaunay_2d(3 uses)UnstructuredGridFilters.delaunay_2d(3 uses)Wavelet(3 uses)351 more
DataObjectFilters.triangulate(2 uses)DataSetFilters.color_labels(2 uses)DataSetFilters.compute_derivative(2 uses)DataSetFilters.contour(2 uses)DataSetFilters.shrink(2 uses)DataSetFilters.tessellate(2 uses)DataSetFilters.threshold(2 uses)DataSetFilters.warp_by_scalar(2 uses)ImageDataFilters.close(2 uses)ImageDataFilters.gaussian_smooth(2 uses)ImageDataFilters.image_threshold(2 uses)ImageDataFilters.median_smooth(2 uses)ImageDataFilters.open(2 uses)ImageDataFilters.resample(2 uses)ImageDataFilters.select_values(2 uses)MultiBlock.plot(2 uses)PartitionedDataSet.plot(2 uses)PointSet.plot(2 uses)PointSet.threshold(2 uses)PolyDataFilters.decimate(2 uses)PolyDataFilters.decimate_pro(2 uses)PolyDataFilters.subdivide(2 uses)PolyDataFilters.subdivide_adaptive(2 uses)PolyDataFilters.triangulate(2 uses)SolidSphere(2 uses)UnstructuredGridFilters.subdivide_tetra(2 uses)download_tri_quadratic_hexahedron(2 uses)plot(2 uses)sample_function(2 uses)AVSucdReader(1 use)Arrow(1 use)BMPReader(1 use)BYUReader(1 use)BinaryMarchingCubesReader(1 use)Box(1 use)Capsule(1 use)Circle(1 use)Cone(1 use)Cube(1 use)CubeFacesSource.explode_factor(1 use)CubeFacesSource.shrink_factor(1 use)Cylinder(1 use)CylinderStructured(1 use)DEMReader(1 use)DICOMReader(1 use)DataObject.copy_attributes(1 use)DataObject.copy_structure(1 use)DataObjectFilters.cell_data_to_point_data(1 use)DataObjectFilters.cell_quality(1 use)DataObjectFilters.clip(1 use)DataObjectFilters.clip_box(1 use)DataObjectFilters.clip_slab(1 use)DataObjectFilters.compute_cell_sizes(1 use)DataObjectFilters.elevation(1 use)DataObjectFilters.extract_all_edges(1 use)DataObjectFilters.point_data_to_cell_data(1 use)DataObjectFilters.reflect(1 use)DataObjectFilters.sample(1 use)DataObjectFilters.slice(1 use)DataObjectFilters.slice_implicit(1 use)DataObjectFilters.transform(1 use)DataSetFilters.clip_scalar(1 use)DataSetFilters.clip_surface(1 use)DataSetFilters.delaunay_3d(1 use)DataSetFilters.explode(1 use)DataSetFilters.extract_feature_edges(1 use)DataSetFilters.extract_largest(1 use)DataSetFilters.extract_points(1 use)DataSetFilters.gaussian_splatting(1 use)DataSetFilters.merge(1 use)DataSetFilters.threshold_percent(1 use)DataSetFilters.voxelize(1 use)DataSetFilters.voxelize_rectilinear(1 use)Disc(1 use)Dodecahedron(1 use)Ellipse(1 use)ExplicitStructuredGrid(1 use)ExplicitStructuredGrid.cast_to_unstructured_grid(1 use)ExplicitStructuredGrid.compute_connections(1 use)ExplicitStructuredGrid.compute_connectivity(1 use)ExplicitStructuredGrid.hide_cells(1 use)ExplicitStructuredGrid.show_cells(1 use)FLUENTCFFReader(1 use)FacetReader(1 use)GESignaReader(1 use)GIFReader(1 use)GambitReader(1 use)Grid.dimensions(1 use)HDFReader(1 use)Icosahedron(1 use)Icosphere(1 use)ImageData.spacing(1 use)ImageData.to_tetrahedra(1 use)ImageDataFilters.concatenate(1 use)ImageDataFilters.label_connectivity(1 use)ImageDataFilters.pad_image(1 use)JPEGReader(1 use)KochanekSpline(1 use)Line(1 use)MINCImageReader(1 use)MetaImageReader(1 use)NIFTIReader(1 use)NRRDReader(1 use)Nek5000Reader(1 use)OBJReader(1 use)Octahedron(1 use)PLYReader(1 use)PNGReader(1 use)PNMReader(1 use)PVDReader(1 use)ParametricBohemianDome(1 use)ParametricBour(1 use)ParametricBoy(1 use)ParametricCatalanMinimal(1 use)ParametricConicSpiral(1 use)ParametricCrossCap(1 use)ParametricDini(1 use)ParametricEllipsoid(1 use)ParametricEnneper(1 use)ParametricFigure8Klein(1 use)ParametricHenneberg(1 use)ParametricKlein(1 use)ParametricKuen(1 use)ParametricMobius(1 use)ParametricPluckerConoid(1 use)ParametricPseudosphere(1 use)ParametricRandomHills(1 use)ParametricRoman(1 use)ParametricSuperEllipsoid(1 use)ParametricSuperToroid(1 use)ParametricTorus(1 use)ParticleReader(1 use)Plane(1 use)PlatonicSolid(1 use)Plotter.enable_ssao(1 use)Plotter.remove_all_lights(1 use)PointSet.delaunay_3d(1 use)PointSet.explode(1 use)PointSet.threshold_percent(1 use)PolyData(1 use)PolyData.from_irregular_faces(1 use)PolyData.from_regular_faces(1 use)PolyData.verts(1 use)PolyDataFilters.append_polydata(1 use)PolyDataFilters.clip_closed_surface(1 use)PolyDataFilters.collision(1 use)PolyDataFilters.compute_arc_length(1 use)PolyDataFilters.curvature(1 use)PolyDataFilters.edge_mask(1 use)PolyDataFilters.extrude(1 use)PolyDataFilters.extrude_rotate(1 use)PolyDataFilters.extrude_trim(1 use)PolyDataFilters.merge(1 use)PolyDataFilters.protein_ribbon(1 use)PolyDataFilters.remove_points(1 use)PolyDataFilters.ribbon(1 use)PolyDataFilters.smooth(1 use)PolyDataFilters.strip(1 use)PolyDataFilters.tube(1 use)Polygon(1 use)ProStarReader(1 use)Pyramid(1 use)Quadrilateral(1 use)Rectangle(1 use)RectilinearGrid(1 use)RectilinearGrid.dimensions(1 use)RectilinearGrid.to_tetrahedra(1 use)Renderer.enable_ssao(1 use)SLCReader(1 use)STLReader(1 use)SeriesReader(1 use)SolidSphereGeneric(1 use)Sphere(1 use)Spline(1 use)StructuredGrid.hide_cells(1 use)StructuredGrid.hide_points(1 use)StructuredSphere(1 use)Superquadric(1 use)TIFFReader(1 use)Tetrahedron(1 use)Text3D(1 use)Triangle(1 use)Tube(1 use)UnstructuredGrid(1 use)UnstructuredGrid.cast_to_explicit_structured_grid(1 use)VTKDataSetReader(1 use)XMLPolyDataReader(1 use)XMLRectilinearGridReader(1 use)XMLStructuredGridReader(1 use)XMLUnstructuredGridReader(1 use)_PointSetBase.remove_cells(1 use)download_3gqp(1 use)download_aero_bracket(1 use)download_angular_sector(1 use)download_antarctica_velocity(1 use)download_armadillo(1 use)download_beach(1 use)download_bird(1 use)download_bird_bath(1 use)download_black_vase(1 use)download_blood_vessels(1 use)download_blow(1 use)download_brain(1 use)download_bunny(1 use)download_bunny_coarse(1 use)download_cad_model(1 use)download_cad_model_case(1 use)download_cake_easy(1 use)download_can_crushed_hdf(1 use)download_can_crushed_vtu(1 use)download_carburetor(1 use)download_carotid(1 use)download_cells_nd(1 use)download_cgns_multi(1 use)download_chest(1 use)download_clown(1 use)download_coastlines(1 use)download_coil_magnetic_field(1 use)download_cow(1 use)download_cow_head(1 use)download_crater_topo(1 use)download_damavand_volcano(1 use)download_delaunay_example(1 use)download_dicom_stack(1 use)download_disc_quads(1 use)download_dolfin(1 use)download_dragon(1 use)download_drill(1 use)download_e07733s002i009(1 use)download_embryo(1 use)download_emoji(1 use)download_face(1 use)download_face2(1 use)download_faults(1 use)download_fea_bracket(1 use)download_fea_hertzian_contact_cylinder(1 use)download_filled_contours(1 use)download_foot_bones(1 use)download_frd(1 use)download_frog(1 use)download_full_head(1 use)download_gif_simple(1 use)download_gourds(1 use)download_gourds_pnm(1 use)download_gpr_path(1 use)download_great_white_shark(1 use)download_grey_nurse_shark(1 use)download_guitar(1 use)download_headsq(1 use)download_honolulu(1 use)download_horse(1 use)download_horse_points(1 use)download_human(1 use)download_iron_protein(1 use)download_ivan_angel(1 use)download_jupiter_surface(1 use)download_kitchen(1 use)download_knee(1 use)download_knee_full(1 use)download_letter_a(1 use)download_letter_k(1 use)download_lidar(1 use)download_lincoln_life_mask(1 use)download_lobster(1 use)download_lshape(1 use)download_mars_surface(1 use)download_masonry_texture(1 use)download_mercury_surface(1 use)download_model_with_variance(1 use)download_moon_surface(1 use)download_moonlanding_image(1 use)download_motor(1 use)download_mount_damavand(1 use)download_nefertiti(1 use)download_nek5000(1 use)download_neptune_surface(1 use)download_notch_displacement(1 use)download_notch_stress(1 use)download_oblique_cone(1 use)download_owl(1 use)download_particles(1 use)download_particles_lethe(1 use)download_pepper(1 use)download_pine_roots(1 use)download_plastic_vase(1 use)download_pluto_surface(1 use)download_poly_line(1 use)download_prism(1 use)download_prostar(1 use)download_prostate(1 use)download_pump_bracket(1 use)download_puppy(1 use)download_room_cff(1 use)download_room_surface_mesh(1 use)download_saddle_surface(1 use)download_saturn_rings(1 use)download_saturn_surface(1 use)download_sea_vase(1 use)download_shark(1 use)download_sky_box_nz(1 use)download_sparse_points(1 use)download_spider(1 use)download_st_helens(1 use)download_stars_cloud_hyg(1 use)download_structured_grid(1 use)download_structured_grid_two(1 use)download_sun_surface(1 use)download_t3_grid_0(1 use)download_teapot(1 use)download_tensors(1 use)download_tetra_dc_mesh(1 use)download_thermal_probes(1 use)download_topo_global(1 use)download_topo_land(1 use)download_torso(1 use)download_trumpet(1 use)download_turbine_blade(1 use)download_unstructured_grid(1 use)download_uranus_surface(1 use)download_urn(1 use)download_usa(1 use)download_venus_surface(1 use)download_vtk(1 use)download_washington_bust(1 use)download_woman(1 use)download_yinyang(1 use)get_reader(1 use)glyphs(1 use)line_segments_from_points(1 use)lines_from_points(1 use)load_airplane(1 use)load_ant(1 use)load_channels(1 use)load_explicit_structured(1 use)load_globe(1 use)load_hexbeam(1 use)load_hydrogen_orbital(1 use)load_logo(1 use)load_nut(1 use)load_planet(1 use)load_planet_rings(1 use)load_random_hills(1 use)load_rectilinear(1 use)load_sphere(1 use)load_spline(1 use)load_structured(1 use)load_tetbeam(1 use)load_uniform(1 use)make_tri_mesh(1 use)merge(1 use)perlin_noise(1 use)
Gallery Examples