pyvista.Property#

class Property(theme=None, interpolation=None, color=None, style='surface', metallic=None, roughness=None, point_size=None, opacity=None, ambient=None, diffuse=None, specular=None, specular_power=None, show_edges=None, edge_color=None, render_points_as_spheres=None, render_lines_as_tubes=None, lighting=None, line_width=None, culling=None, edge_opacity=None)[source]#

Wrap vtkProperty and expose it pythonically.

This class is used to set the property of actors.

Parameters:
themepyvista.plotting.themes.Theme, optional

Plot-specific theme.

interpolationstr, default: pyvista.plotting.themes._LightingConfig.interpolation

Set the method of shading. One of the following:

  • 'Physically based rendering' - Physically based rendering.

  • 'pbr' - Alias for Physically based rendering.

  • 'Phong' - Phong shading.

  • 'Gouraud' - Gouraud shading.

  • 'Flat' - Flat Shading.

This parameter is case insensitive.

colorColorLike, default: pyvista.plotting.themes.Theme.color

Used to make the entire mesh have a single solid color. Either a string, RGB list, or hex color string. For example: color='white', color='w', color=[1.0, 1.0, 1.0], or color='#FFFFFF'. Color will be overridden if scalars are specified.

stylestr, default: ‘surface’

Visualization style of the mesh. One of the following: style='surface', style='wireframe', style='points'. Note that 'wireframe' only shows a wireframe of the outer geometry.

metallicfloat, default: pyvista.plotting.themes._LightingConfig.metallic

Usually this value is either 0 or 1 for a real material but any value in between is valid. This parameter is only used by PBR interpolation.

roughnessfloat, default: pyvista.plotting.themes._LightingConfig.roughness

This value has to be between 0 (glossy) and 1 (rough). A glossy material has reflections and a high specular part. This parameter is only used by PBR interpolation.

point_sizefloat, default: pyvista.plotting.themes.Theme.point_size

Size of the points represented by this property.

opacityfloat, default: pyvista.plotting.themes.Theme.opacity

Opacity of the mesh. A single float value that will be applied globally opacity of the mesh and uniformly applied everywhere - should be between 0 and 1.

ambientfloat, default: pyvista.plotting.themes._LightingConfig.ambient

When lighting is enabled, this is the amount of light in the range of 0 to 1 that reaches the actor when not directed at the light source emitted from the viewer.

diffusefloat, default: pyvista.plotting.themes._LightingConfig.diffuse

The diffuse lighting coefficient.

specularfloat, default: pyvista.plotting.themes._LightingConfig.specular

The specular lighting coefficient.

specular_powerfloat, default: pyvista.plotting.themes._LightingConfig.specular_power

The specular power. Must be between 0.0 and 128.0.

show_edgesbool, default: pyvista.plotting.themes.Theme.show_edges

Shows the edges. Does not apply to a wireframe representation.

edge_colorColorLike, default: pyvista.plotting.themes.Theme.edge_color

The solid color to give the edges when show_edges=True. Either a string, RGB list, or hex color string.

render_points_as_spheresbool, default: pyvista.plotting.themes.Theme.render_points_as_spheres

Render points as spheres rather than dots.

render_lines_as_tubesbool, default: pyvista.plotting.themes.Theme.render_lines_as_tubes

Show lines as thick tubes rather than flat lines. Control the width with line_width.

lightingbool, default: pyvista.plotting.themes.Theme.lighting

Enable or disable view direction lighting.

line_widthfloat, default: pyvista.plotting.themes.Theme.line_width

Thickness of lines. Only valid for wireframe and surface representations.

cullingstr | bool, optional

Does not render faces that are culled. This can be helpful for dense surface meshes, especially when edges are visible, but can cause flat meshes to be partially displayed. Defaults to 'none'. One of the following:

  • "back" - Enable backface culling

  • "front" - Enable frontface culling

  • 'none' - Disable both backface and frontface culling

edge_opacityfloat, default: pyvista.plotting.themes.Theme.edge_opacity

Edge opacity of the mesh. A single float value that will be applied globally edge opacity of the mesh and uniformly applied everywhere - should be between 0 and 1.

Note

edge_opacity uses SetEdgeOpacity as the underlying method which requires VTK version 9.3 or higher. If SetEdgeOpacity is not available, edge_opacity is set to 1.

Examples

Create a pyvista.Actor and assign properties to it.

>>> import pyvista as pv
>>> actor = pv.Actor()
>>> actor.prop = pv.Property(
...     color='r',
...     show_edges=True,
...     interpolation='Physically based rendering',
...     metallic=0.5,
...     roughness=0.1,
... )

Visualize how the property would look when applied to a mesh.

>>> actor.prop.plot()
../../../_images/pyvista-Property-1_00_00.png

Set custom properties not directly available in pyvista.Plotter.add_mesh(). Here, we set diffuse, ambient, and specular power and colors.

>>> pl = pv.Plotter()
>>> actor = pl.add_mesh(pv.Sphere())
>>> prop = actor.prop
>>> prop.diffuse = 0.6
>>> prop.diffuse_color = 'w'
>>> prop.ambient = 0.3
>>> prop.ambient_color = 'r'
>>> prop.specular = 0.5
>>> prop.specular_color = 'b'
>>> pl.show()
../../../_images/pyvista-Property-1_01_00.png

Methods

Property.copy()

Create a deep copy of this property.

Property.plot(**kwargs)

Plot this property on the Stanford Bunny.

Attributes

Property.ambient

Return or set ambient.

Property.ambient_color

Return or set the ambient color of this property.

Property.anisotropy

Return or set the anisotropy coefficient.

Property.color

Return or set the color of this property.

Property.culling

Return or set face culling.

Property.diffuse

Return or set the diffuse lighting coefficient.

Property.diffuse_color

Return or set the diffuse color of this property.

Property.edge_color

Return or set the edge color of this property.

Property.edge_opacity

Return or set the edge opacity of this property.

Property.interpolation

Return or set the method of shading.

Property.lighting

Return or set view direction lighting.

Property.line_width

Return or set the line width.

Property.metallic

Return or set metallic.

Property.opacity

Return or set the opacity of this property.

Property.point_size

Return or set the point size.

Property.render_lines_as_tubes

Return or set rendering lines as tubes.

Property.render_points_as_spheres

Return or set rendering points as spheres.

Property.roughness

Return or set roughness.

Property.show_edges

Return or set the visibility of edges.

Property.specular

Return or set specular.

Property.specular_color

Return or set the specular color of this property.

Property.specular_power

Return or set specular power.

Property.style

Return or set Visualization style of the mesh.