spateo.plotting.static.three_d_plot.three_dims_plotter#

Module Contents#

Functions#

_get_default_cmap()

create_plotter(, background, shape, list, tuple] =, ...)

Create a plotting object to display pyvista/vtk model.

_set_jupyter([jupyter, off_screen])

add_model(plotter, model[, key, colormap, ambient, ...])

Add model(s) to the plotter.

add_str_legend(plotter, labels, colors, legend_size, ...)

Add a string legend to the plotter.

add_num_legend(plotter[, title, title_font_size, ...])

Add a numeric legend (colorbar) to the plotter.

add_legend(plotter, model[, key, colormap, ...])

Add a legend to the plotter.

add_outline(plotter, model[, outline_width, ...])

Produce an outline of the full extent for the model.

add_text(plotter, text[, font_family, font_size, ...])

Add text to the plotter.

output_plotter(plotter[, filename, view_up, ...])

Output plotter as image, gif file or mp4 file.

save_plotter(plotter, filename)

Save plotter as gltf file, html file, obj file or vtkjs file.

spateo.plotting.static.three_d_plot.three_dims_plotter._get_default_cmap()[source]#
spateo.plotting.static.three_d_plot.three_dims_plotter.create_plotter(jupyter: bool = False, off_screen: bool = False, window_size: tuple = (512, 512), background: str = 'white', shape: str | list | tuple = (1, 1), show_axes: bool = True) pyvista.Plotter[source]#

Create a plotting object to display pyvista/vtk model.

Parameters:
jupyter

Whether to plot in jupyter notebook.

off_screen

Renders off-screen when True. Useful for automated screenshots.

window_size

Window size in pixels. The default window_size is [1024, 768].

background

The background color of the window.

shape

Number of sub-render windows inside the main window. By default, there is only one render window.

  • Specify two across with ``shape``=(2, 1) and a two by two grid with ``shape``=(2, 2).

  • shape Can also accept a string descriptor as shape.

    E.g.: shape="3|1" means 3 plots on the left and 1 on the right, E.g.: shape="4/2" means 4 plots on top and 2 at the bottom.

show_axes

Whether to add a camera orientation widget to the active renderer.

Returns:

The plotting object to display pyvista/vtk model.

Return type:

plotter

spateo.plotting.static.three_d_plot.three_dims_plotter._set_jupyter(jupyter: bool | Literal[trame, none, static] = False, off_screen: bool = False)[source]#
spateo.plotting.static.three_d_plot.three_dims_plotter.add_model(plotter: pyvista.Plotter, model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock | list, key: str | list = None, colormap: str | list | None = None, ambient: float | list = 0.2, opacity: float | list | numpy.ndarray = 1.0, model_style: Literal[points, surface, wireframe] | list = 'surface', model_size: float | list = 3.0)[source]#

Add model(s) to the plotter.

Parameters:
plotter

The plotting object to display pyvista/vtk model.

model

A reconstructed model.

key

The key under which are the labels.

colormap

Name of the Matplotlib colormap to use when mapping the scalars.

When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.

ambient

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

opacity

Opacity of the model.

If a single float value is given, it will be the global opacity of the model and uniformly applied everywhere, elif a numpy.ndarray with single float values is given, it will be the opacity of each point. - should be between 0 and 1.

A string can also be specified to map the scalars range to a predefined opacity transfer function (options include: ‘linear’, ‘linear_r’, ‘geom’, ‘geom_r’).

model_style

Visualization style of the model. One of the following:

  • model_style = 'surface',

  • model_style = 'wireframe',

  • model_style = 'points'.

model_size

If model_style = 'points', point size of any nodes in the dataset plotted.

If model_style = 'wireframe', thickness of lines.

spateo.plotting.static.three_d_plot.three_dims_plotter.add_str_legend(plotter: pyvista.Plotter, labels: numpy.ndarray, colors: numpy.ndarray, legend_size: Optional[Tuple] = None, legend_loc: Literal[upper right, upper left, lower left, lower right, center left, center right, lower center, upper center, center] = 'lower right')[source]#

Add a string legend to the plotter.

Parameters:
plotter

The plotting object to display pyvista/vtk model.

labels

Legend labels.

colors

The colors corresponding to the legend labels.

legend_size

The percentage (0 to 1) width and height of the window for the legend.

For example (0.1, 0.1) would make the legend 10% the size of the entire figure window.

If legend_size is None, legend_size will be adjusted adaptively.

legend_loc

The location of the legend in the window. Available legend_loc are:

  • legend_loc = 'upper right'

  • legend_loc = 'upper left'

  • legend_loc = 'lower left'

  • legend_loc = 'lower right'

  • legend_loc = 'center left'

  • legend_loc = 'center right'

  • legend_loc = 'lower center'

  • legend_loc = 'upper center'

  • legend_loc = 'center'

spateo.plotting.static.three_d_plot.three_dims_plotter.add_num_legend(plotter: pyvista.Plotter, title: str | None = '', title_font_size: int | float | None = None, label_font_size: int | float | None = None, font_color: str = 'black', font_family: Literal[times, courier, arial] = 'arial', fmt='%.2e', n_labels: int = 5, legend_size: tuple | list = (0.1, 0.4), legend_loc: tuple | list = (0.85, 0.3), vertical: bool = True)[source]#

Add a numeric legend (colorbar) to the plotter.

Parameters:
plotter

The plotting object to display pyvista/vtk model.

title

Title of the legend. Default ‘’ which is rendered as an empty title.

title_font_size

Sets the size of the title font.

label_font_size

Sets the size of the label font.

font_color

The color of the font.

font_family

The font of the text. Available font_family are:

  • font_family = times

  • font_family = courier

  • font_family = arial

fmt

printf format for labels.

n_labels

Number of labels to use for the legend.

legend_size

The percentage (0 to 1) width and height of the window for the legend.

legend_loc

The location of the legend in the window.

legend_loc[0]: The percentage (0 to 1) along the windows’s horizontal direction to place the bottom left corner of the legend. legend_loc[1]: The percentage (0 to 1) along the windows’s vertical direction to place the bottom left corner of the legend.

vertical

Use vertical or horizontal legend.

spateo.plotting.static.three_d_plot.three_dims_plotter.add_legend(plotter: pyvista.Plotter, model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock, key: str | list | None = None, colormap: str | list | None = None, legend_size: Tuple | None = None, legend_loc: str | tuple | list = None, title: str | None = '', title_font_size: int | float | None = None, label_font_size: int | float | None = None, font_color: str = 'black', font_family: Literal[times, courier, arial] = 'arial', fmt='%.2e', n_labels: int = 5, vertical: bool = True)[source]#

Add a legend to the plotter.

Parameters:
plotter

The plotting object to display pyvista/vtk model.

model

A reconstructed model.

key

The key under which are the legend labels.

colormap

Name of the Matplotlib colormap to use when mapping the scalars.

When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.

legend_size

The percentage (0 to 1) width and height of the window for the legend.

legend_loc

The location of the legend in the window.

title

Title of the legend. Default ‘’ which is rendered as an empty title.

title_font_size

Sets the size of the title font. Only available when colormap is not None.

label_font_size

Sets the size of the label font. Only available when colormap is not None.

font_color

The color of the font. Only available when colormap is not None.

font_family

The font of the text. Only available when colormap is not None.

Available font_family are:

  • font_family = times

  • font_family = courier

  • font_family = arial

fmt

printf format for labels. Only available when colormap is not None.

n_labels

Number of labels to use for the legend. Only available when colormap is not None.

vertical

Use vertical or horizontal legend. Only available when colormap is not None.

spateo.plotting.static.three_d_plot.three_dims_plotter.add_outline(plotter: pyvista.Plotter, model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock, outline_width: float = 5.0, outline_color: str | tuple = 'black', show_labels: bool = True, font_size: int = 16, font_color: str | tuple = 'white', font_family: Literal[times, courier, arial] = 'arial')[source]#

Produce an outline of the full extent for the model. If labels is True, add the length, width and height information of the model to the outline.

Parameters:
plotter

The plotting object to display pyvista/vtk model.

model

A reconstructed model.

outline_width

The width of the outline.

outline_color

The color of the outline.

show_labels

Whether to add the length, width and height information of the model to the outline.

font_family

The font family of the text. Available font_family are:

  • font_family = times

  • font_family = courier

  • font_family = arial

font_size

The size of the font.

font_color

The color of the font.

spateo.plotting.static.three_d_plot.three_dims_plotter.add_text(plotter: pyvista.Plotter, text: str, font_family: Literal[times, courier, arial] = 'arial', font_size: int | float = 15, font_color: str | tuple | list = 'black', text_loc: Literal[lower_left, lower_right, upper_left, upper_right, lower_edge, upper_edge, right_edge, left_edge] = 'upper_left')[source]#

Add text to the plotter.

Parameters:
plotter

The plotting object to display pyvista/vtk model.

text

The text to add the rendering.

font_family

The font family of the text. Available font_family are:

  • font_family = times

  • font_family = courier

  • font_family = arial

font_size

The size of the font.

font_color

The color of the font.

text_loc

The location of the text in the window. Available text_loc are:

  • text_loc = 'lower_left'

  • text_loc = 'lower_right'

  • text_loc = 'upper_left'

  • text_loc = 'upper_right'

  • text_loc = 'lower_edge'

  • text_loc = 'upper_edge'

  • text_loc = 'right_edge'

  • text_loc = 'left_edge'

spateo.plotting.static.three_d_plot.three_dims_plotter.output_plotter(plotter: pyvista.Plotter, filename: str | None = None, view_up: tuple = (0.5, 0.5, 1), framerate: int = 15, jupyter: bool | Literal[trame, none, static] = False)[source]#

Output plotter as image, gif file or mp4 file.

Parameters:
plotter

The plotting object to display pyvista/vtk model.

filename

Filename of output file. Writer type is inferred from the extension of the filename.

  • Output an image file,please enter a filename ending with '.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'. When jupyter=False, if you want to save ‘.png’ file, please ensure off_screen=True.

  • Output a gif file, please enter a filename ending with .gif.

  • Output a mp4 file, please enter a filename ending with .mp4.

view_up

The normal to the orbital plane. Only available when filename ending with .mp4 or .gif.

framerate

Frames per second. Only available when filename ending with .mp4 or .gif.

jupyter

Whether to plot in jupyter notebook. Available jupyter are:

  • 'none' - Do not display in the notebook.

  • 'trame' - Show a trame widget

  • 'static' - Display a static figure.

Returns:

List of camera position, focal point, and view up.

Returned only if filename is None or filename ending with '.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'.

img: Numpy array of the last image.

Returned only if filename is None or filename ending with '.png', '.tif', '.tiff', '.bmp', '.jpeg', '.jpg', '.svg', '.eps', '.ps', '.pdf', '.tex'.

Return type:

cpo

spateo.plotting.static.three_d_plot.three_dims_plotter.save_plotter(plotter: pyvista.Plotter, filename: str)[source]#

Save plotter as gltf file, html file, obj file or vtkjs file.

Parameters:
plotter

The plotting object to display pyvista/vtk model.

filename

The filename of the file where the plotter is saved.

Writer type is inferred from the extension of the filename.

  • Output a gltf file, please enter a filename ending with .gltf.

  • Output a html file, please enter a filename ending with .html.

  • Output an obj file, please enter a filename ending with .obj.

  • Output a vtkjs file, please enter a filename without format.