spateo.plotting.static.three_d_plot¶
Submodules¶
- spateo.plotting.static.three_d_plot.align_plots
- spateo.plotting.static.three_d_plot.backbone_plots
- spateo.plotting.static.three_d_plot.morphometrics_plots
- spateo.plotting.static.three_d_plot.pairwise_align_plots
- spateo.plotting.static.three_d_plot.three_dims_plots
- spateo.plotting.static.three_d_plot.three_dims_plotter
Functions¶
|
|
|
Visualize multiple models separately in one figure. |
|
Visualize constructed 3D backbone model. |
|
Visualize the torsion result. |
|
Visualize the curl result. |
|
Visualize the curvature result. |
|
Visualize the divergence result. |
|
Visualize the jacobian result. |
|
Visualize the torsion result. |
|
Visualize the results of each iteration in the alignment process. |
|
|
|
Visualize the pairing of cells between two models. |
|
Visualize a heatmap of the pi matrix. |
|
Use MoviePy to compose a new animation and play multiple animations together in the new animation. |
|
Animated visualization of 3D reconstruction model. |
|
Multi-view visualization of reconstructed 3D model. |
|
Visualize reconstructed 3D model. |
Package Contents¶
- spateo.plotting.static.three_d_plot.deformation(*adata: anndata.AnnData, deformed_grid: pyvista.PolyData | List[pyvista.PolyData], layer: str = 'X', group_key: str | list = None, spatial_key: str = 'align_spatial', id_key: str = 'slices', deformation_key: str | None = 'deformation', center_zero: bool = False, show_model: bool = True, filename: str | None = None, jupyter: bool | Literal['none', 'static', 'trame'] = False, off_screen: bool = False, cpo: str | list = 'xy', shape: str | list | tuple = None, window_size: tuple | None = (1024, 756), background: str = 'white', model_color: str | list = 'red', model_alpha: float | list | dict = 1, colormap: str | list | dict = 'black', alphamap: float | list | dict = 1.0, ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, grid_size: float | list = 2.0, model_size: float | list = 3.0, show_axes: bool = True, show_legend: bool = False, legend_kwargs: dict | None = None, text: bool | str = True, text_kwargs: dict | None = None, **kwargs)[source]¶
- spateo.plotting.static.three_d_plot.multi_models(*adata: anndata.AnnData, layer: str = 'X', group_key: str | list = None, spatial_key: str = 'align_spatial', id_key: str = 'slices', mode: Literal['single', 'overlap', 'both'] = 'single', center_zero: bool = False, filename: str | None = None, jupyter: bool | Literal['none', 'static', 'trame'] = False, off_screen: bool = False, cpo: str | list = 'xy', shape: str | list | tuple = None, window_size: tuple | None = None, background: str = 'white', colormap: str | list | dict = 'red', overlap_cmap: str | list | dict = 'dodgerblue', alphamap: float | list | dict = 1.0, overlap_amap: float | list | dict = 0.5, ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, model_size: float | list = 3.0, show_axes: bool = True, show_legend: bool = True, legend_kwargs: dict | None = None, text: bool | str = True, text_kwargs: dict | None = None, **kwargs)[source]¶
Visualize multiple models separately in one figure.
- Parameters:
- *adata
A list of models[Anndata object].
- layer
If
'X'
, uses.X
, otherwise uses the representation given by.layers[layer]
.- group_key
The key that stores clustering or annotation information in
.obs
, a gene name or a list of gene names in.var
.- spatial_key
The key in
.obsm
that corresponds to the spatial coordinate of each bucket.- id_key
The key in
.obs
that corresponds to the model id of each bucket.- mode
Three modes of visualization. Available
mode
are:'single'
- Visualize each model individually.'overlap'
- Simultaneously visualize two models aligned front to back in one subplot.'both'
- Simultaneously visualize both types above.
- center_zero
Whether to move the center point of the model to the (0, 0, 0).
- 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'
. Whenjupyter=False
, if you want to save ‘.png’ file, please ensureoff_screen=True
.
- 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.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- cpo
Camera position of the active render window. Available
cpo
are:- Iterable containing position, focal_point, and view up.
E.g.: [(2.0, 5.0, 13.0), (0.0, 0.0, 0.0), (-0.7, -0.5, 0.3)].
- Iterable containing a view vector.
E.g.: [-1.0, 2.0, -5.0].
- A string containing the plane orthogonal to the view direction.
E.g.: 'xy', 'xz', 'yz', 'yx', 'zx', 'zy', 'iso'.
- shape
Number of sub-render windows inside the main window. By default, there is only one render window.
- window_size
Window size in pixels. The default window_size is
[512, 512]
.- background
The background color of the window.
- colormap
Colors to use for plotting pc. The default colormap is
'dodgerblue'
.- overlap_cmap
Colors to use for plotting overlapped pc. The default colormap is
'red'
.- alphamap
The opacity of the colors to use for plotting pc. The default alphamap is
1.0
.- overlap_amap
The opacity of the colors to use for plotting overlapped pc. The default alphamap is
.5
.- 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_size
The point size of any nodes in the dataset plotted.
- show_axes
Whether to add a camera orientation widget to the active renderer.
- show_legend
whether to add a legend to the plotter.
- legend_kwargs
A dictionary that will be pass to the
add_legend
function.By default, it is an empty dictionary and the
add_legend
function will use the{"legend_size": None, "legend_loc": None, "legend_size": None, "legend_loc": None, "title_font_size": None, "label_font_size": None, "font_family": "arial", "fmt": "%.2e", "n_labels": 5, "vertical": True}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- text
The text to add the rendering.
- text_kwargs
A dictionary that will be pass to the
add_text
function.By default, it is an empty dictionary and the
add_legend
function will use the{ "font_family": "arial", "font_size": 12, "font_color": "black", "text_loc": "upper_left"}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- **kwargs
Additional parameters that will be passed to
three_d_multi_plot
function.
- spateo.plotting.static.three_d_plot.backbone(backbone_model: pyvista.PolyData, backbone_key: str = 'backbone', backbone_model_size: float | int = 8, backbone_colormap: str | None = None, backbone_ambient: float | list = 0.2, backbone_opacity: float | numpy.ndarray | list = 1.0, nodes_key: str | None = 'nodes', nodes_label_size: float | int = 18, bg_model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock | None = None, bg_key: str | list | None = None, bg_model_style: Literal['points', 'surface', 'wireframe'] | list = 'points', bg_model_size: float | list = 10, bg_colormap: str | list | None = None, bg_ambient: float | list = 0.2, bg_opacity: float | numpy.ndarray | list = 0.6, show_axes: bool = True, show_legend: bool = True, legend_kwargs: dict | None = None, filename: str | None = None, jupyter: bool | Literal['none', 'static', 'trame'] = False, off_screen: bool = False, window_size: tuple = (2048, 2048), background: str = 'white', cpo: str | list = 'iso', **kwargs)[source]¶
Visualize constructed 3D backbone model.
- Parameters:
- backbone_model
The constructed backbone model.
- backbone_key
Any point_data names or cell_data names to be used for coloring
backbone_model
.- backbone_model_size
The thickness of backbone.
- backbone_colormap
Name of the Matplotlib colormap to use when mapping the scalars of
backbone_model
.When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- backbone_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.
- backbone_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’).
- nodes_key
The key that corresponds to the coordinates of the nodes in the backbone.
- nodes_label_size
Sets the size of the title font.
- bg_model
The background model used to construct backbone model.
- bg_key
Any point_data names or cell_data names to be used for coloring
bg_model
.- bg_model_style
Visualization style of
bg_model
. One of the following:bg_model_style = 'surface'
,bg_model_style = 'wireframe'
,bg_model_style = 'points'
.
- bg_model_size
If
bg_model_style = 'points'
, point size of any nodes in the dataset plotted.If
bg_model_style = 'wireframe'
, thickness of lines.- bg_colormap
Name of the Matplotlib colormap to use when mapping the scalars of
bg_model
.When the colormap is None, use {key}_rgba to map the scalars, otherwise use the colormap to map scalars.
- bg_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.
- bg_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’).
- show_axes
Whether to add a camera orientation widget to the active renderer.
- show_legend
whether to add a legend of
bg_model
to the plotter.- legend_kwargs
A dictionary that will be pass to the
add_legend
function. By default, it is an empty dictionary and theadd_legend
function will use the{"legend_size": None, "legend_loc": None, "legend_size": None, "legend_loc": None, "title_font_size": None, "label_font_size": None, "font_family": "arial", "fmt": "%.2e", "n_labels": 5, "vertical": True}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- 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'
. Whenjupyter=False
, if you want to save ‘.png’ file, please ensureoff_screen=True
.
- 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.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- window_size
Window size in pixels. The default window_size is
[512, 512]
.- background
The background color of the window.
- cpo
Camera position of the active render window. Available
cpo
are:- Iterable containing position, focal_point, and view up.
E.g.: [(2.0, 5.0, 13.0), (0.0, 0.0, 0.0), (-0.7, -0.5, 0.3)].
- Iterable containing a view vector.
E.g.: [-1.0, 2.0, -5.0].
- A string containing the plane orthogonal to the view direction.
E.g.: 'xy', 'xz', 'yz', 'yx', 'zx', 'zy', 'iso'.
- **kwargs
Additional parameters that will be passed to
.add_point_labels
function.
- 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.acceleration(adata: anndata.AnnData, model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock | list, acceleration_key: str = 'acceleration', filename: str | None = None, jupyter: bool | Literal['none', 'static', 'trame'] = False, colormap: str | list | None = 'default_cmap', ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, model_style: Literal['points', 'surface', 'wireframe'] | list = 'points', model_size: float | list = 3.0, **kwargs)[source]¶
Visualize the torsion result.
- Parameters:
- adata
An anndata object contain acceleration values in
.obs[acceleration_key]
.- model
A reconstructed model contains
obs_index
values.- acceleration_key
The key in
.obs
that corresponds to the acceleration values in the anndata object.- 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'
. Whenjupyter=False
, if you want to save ‘.png’ file, please ensureoff_screen=True
.Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- 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.
- 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.- **kwargs
Additional parameters that will be passed into the
st.pl.feature
function.
- 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
Examples
Visualize only in one model:
- st.pl.acceleration(
adata=stage_adata, model=stage_pc, acceleration_key=”acceleration”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.acceleration(
adata=stage_adata, model=[stage_pc, trajectory_model], acceleration_key=”acceleration”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)
- spateo.plotting.static.three_d_plot.curl(adata: anndata.AnnData, model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock | list, curl_key: str = 'curl', filename: str | None = None, jupyter: bool | Literal['none', 'static', 'trame'] = False, colormap: str | list | None = 'default_cmap', ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, model_style: Literal['points', 'surface', 'wireframe'] | list = 'points', model_size: float | list = 3.0, **kwargs)[source]¶
Visualize the curl result.
- Parameters:
- adata
An anndata object contain curl values in
.obs[curl_key]
.- model
A reconstructed model contains
obs_index
values.- curl_key
The key in
.obs
that corresponds to the curl values in the anndata object.- 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'
. Whenjupyter=False
, if you want to save ‘.png’ file, please ensureoff_screen=True
.Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- 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.
- 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.- **kwargs
Additional parameters that will be passed into the
st.pl.feature
function.
- 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
Examples
Visualize only in one model:
- st.pl.curl(
adata=stage_adata, model=stage_pc, curl_key=”curl”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.curl(
adata=stage_adata, model=[stage_pc, trajectory_model], curl_key=”curl”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)
- spateo.plotting.static.three_d_plot.curvature(adata: anndata.AnnData, model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock | list, curvature_key: str = 'curvature', filename: str | None = None, jupyter: bool | Literal['none', 'static', 'trame'] = False, colormap: str | list | None = 'default_cmap', ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, model_style: Literal['points', 'surface', 'wireframe'] | list = 'points', model_size: float | list = 3.0, **kwargs)[source]¶
Visualize the curvature result.
- Parameters:
- adata
An anndata object contain curvature values in
.obs[curvature_key]
.- model
A reconstructed model contains
obs_index
values.- curvature_key
The key in
.obs
that corresponds to the curvature values in the anndata object.- 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'
. Whenjupyter=False
, if you want to save ‘.png’ file, please ensureoff_screen=True
.Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- 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.
- 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.- **kwargs
Additional parameters that will be passed into the
st.pl.feature
function.
- 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
Examples
Visualize only in one model:
- st.pl.curvature(
adata=stage_adata, model=stage_pc, curvature_key=”curvature”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.curvature(
adata=stage_adata, model=[stage_pc, trajectory_model], curvature_key=”curvature”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)
- spateo.plotting.static.three_d_plot.divergence(adata: anndata.AnnData, model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock | list, divergence_key: str = 'divergence', filename: str | None = None, jupyter: bool | Literal['none', 'static', 'trame'] = False, colormap: str | list | None = 'default_cmap', ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, model_style: Literal['points', 'surface', 'wireframe'] | list = 'points', model_size: float | list = 3.0, **kwargs)[source]¶
Visualize the divergence result.
- Parameters:
- adata
An anndata object contain curl values in
.obs[divergence_key]
.- model
A reconstructed model contains
obs_index
values.- divergence_key
The key in
.obs
that corresponds to the divergence values in the anndata object.- 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'
. Whenjupyter=False
, if you want to save ‘.png’ file, please ensureoff_screen=True
.Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- jupyter
Whether to plot in jupyter notebook. Available
jupyter
are:'none'
- Do not display in the notebook.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- 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.- **kwargs
Additional parameters that will be passed into the
st.pl.feature
function.
- 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
Examples
Visualize only in one model:
- st.pl.divergence(
adata=stage_adata, model=stage_pc, divergence_key=”divergence”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.divergence(
adata=stage_adata, model=[stage_pc, trajectory_model], divergence_key=”divergence”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)
- spateo.plotting.static.three_d_plot.jacobian(adata: anndata.AnnData, model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock | list, jacobian_key: str = 'jacobian', filename: str | None = None, jupyter: bool | Literal['none', 'static', 'trame'] = False, off_screen: bool = False, shape: str | list | tuple = (3, 3), window_size: tuple | None = (512 * 3, 512 * 3), background: str = 'black', colormap: str | list | None = 'default_cmap', ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, model_style: Literal['points', 'surface', 'wireframe'] | list = 'points', model_size: float | list = 3.0, show_axes: bool = True, show_legend: bool = True, legend_kwargs: dict | None = None, text: bool | str = True, text_kwargs: dict | None = None, **kwargs)[source]¶
Visualize the jacobian result.
- Parameters:
- adata
An anndata object contain jacobian matrix in
.uns[jacobian_key]
.- model
A reconstructed model contains
obs_index
values.- jacobian_key
The key in
.uns
that corresponds to the jacobian matrix in the anndata object.- 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'
. Whenjupyter=False
, if you want to save ‘.png’ file, please ensureoff_screen=True
.Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- 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.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- shape
Number of sub-render windows inside the main window. By default, there are nine render window.
- window_size
Window size in pixels. The default window_size is
[512*3, 512*3]
.- background
The background color of the window.
- 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.- show_axes
Whether to add a camera orientation widget to the active renderer.
- show_legend
whether to add a legend to the plotter.
- legend_kwargs
A dictionary that will be pass to the
add_legend
function. By default, it is an empty dictionary and theadd_legend
function will use the{"legend_size": None, "legend_loc": None, "legend_size": None, "legend_loc": None, "title_font_size": None, "label_font_size": None, "font_family": "arial", "fmt": "%.2e", "n_labels": 5, "vertical": True}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- text
The text to add the rendering.
- text_kwargs
A dictionary that will be pass to the
add_text
function.By default, it is an empty dictionary and the
add_legend
function will use the{ "font_family": "arial", "font_size": 12, "font_color": "black", "text_loc": "upper_left"}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- **kwargs
Additional parameters that will be passed into the
st.pl.three_d_multi_plot
function.
- 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
Examples
Visualize only in one model:
- st.pl.jacobian(
adata=stage_adata, model=stage_pc, jacobian_key=”jacobian”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.jacobian(
adata=stage_adata, model=[stage_pc, trajectory_model], jacobian_key=”jacobian”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)
- spateo.plotting.static.three_d_plot.torsion(adata: anndata.AnnData, model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock | list, torsion_key: str = 'torsion', filename: str | None = None, jupyter: bool | Literal['none', 'static', 'trame'] = False, colormap: str | list | None = 'default_cmap', ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, model_style: Literal['points', 'surface', 'wireframe'] | list = 'points', model_size: float | list = 3.0, **kwargs)[source]¶
Visualize the torsion result.
- Parameters:
- adata
An anndata object contain torsion values in
.obs[torsion_key]
.- model
A reconstructed model contains
obs_index
values.- torsion_key
The key in
.obs
that corresponds to the torsion values in the anndata object.- 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'
. Whenjupyter=False
, if you want to save ‘.png’ file, please ensureoff_screen=True
.Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- 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.
- 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.- **kwargs
Additional parameters that will be passed into the
st.pl.feature
function.
- 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
Examples
Visualize only in one model:
- st.pl.torsion(
adata=stage_adata, model=stage_pc, torsion_key=”torsion”, jupyter=”static”, model_style=”points”, model_size=3
)
Visualize in multiple model:
- st.pl.torsion(
adata=stage_adata, model=[stage_pc, trajectory_model], torsion_key=”torsion”, jupyter=”static”, model_style=[“points”, “wireframe”], model_size=[3, 1]
)
- spateo.plotting.static.three_d_plot.pairwise_iteration(adataA: anndata.AnnData, adataB: anndata.AnnData, layer: str = 'X', group_key: str | list = None, spatial_key: str = 'align_spatial', iter_key: str = 'iter_spatial', id_key: str = 'slices', filename: str = 'animate.mp4', jupyter: bool | Literal['none', 'static', 'trame'] = False, off_screen: bool = False, cpo: str | list | None = None, window_size: tuple | None = None, background: str = 'black', modelA_cmap: str = 'dodgerblue', modelB_cmap: str = 'red', ambient: int | float = 0.3, modelA_opacity: int | float = 0.8, modelB_opacity: int | float = 1.0, model_size: float | list = 6.0, show_axes: bool = True, show_legend: bool = True, legend_kwargs: dict | None = None, text: bool | str = True, text_kwargs: dict | None = None, framerate: int = 6, **kwargs)[source]¶
Visualize the results of each iteration in the alignment process.
- Parameters:
- adataA
Anndata object of modelA.
- adataB
Anndata object of modelB.
- layer
If
'X'
, uses.X
, otherwise uses the representation given by.layers[layer]
.- group_key
The key that stores clustering or annotation information in
.obs
, a gene name or a list of gene names in.var
.- spatial_key
The key in
.obsm
that corresponds to the spatial coordinate of each bucket.- iter_key
The key in
.uns
that corresponds to the result of each iteration of the iterative process.- id_key
The key in
.obs
that corresponds to the model id of each bucket.- filename
Filename of output file. Writer type is inferred from the extension of the filename.
Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- 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.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- cpo
Camera position of the active render window. Available
cpo
are:- Iterable containing position, focal_point, and view up.
E.g.: [(2.0, 5.0, 13.0), (0.0, 0.0, 0.0), (-0.7, -0.5, 0.3)].
- Iterable containing a view vector.
E.g.: [-1.0, 2.0, -5.0].
- A string containing the plane orthogonal to the view direction.
E.g.: 'xy', 'xz', 'yz', 'yx', 'zx', 'zy', 'iso'.
- window_size
Window size in pixels. The default window_size is
[512, 512]
.- background
The background color of the window.
- modelA_cmap
Colors to use for plotting modelA. The default colormap is
'dodgerblue'
.- modelB_cmap
Colors to use for plotting modelB. The default colormap is
'red'
.- 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.
- modelA_opacity
Opacity of the modelA.
- modelB_opacity
Opacity of the modelB.
- model_size
The point size of any nodes in the dataset plotted.
- show_axes
Whether to add a camera orientation widget to the active renderer.
- show_legend
whether to add a legend to the plotter.
- legend_kwargs
A dictionary that will be pass to the
add_legend
function.By default, it is an empty dictionary and the
add_legend
function will use the{"legend_size": None, "legend_loc": None, "legend_size": None, "legend_loc": None, "title_font_size": None, "label_font_size": None, "font_family": "arial", "fmt": "%.2e", "n_labels": 5, "vertical": True}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- text
The text to add the rendering.
- text_kwargs
A dictionary that will be pass to the
add_text
function.By default, it is an empty dictionary and the
add_legend
function will use the{ "font_family": "arial", "font_size": 12, "font_color": "black", "text_loc": "upper_left"}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- framerate
Frames per second.
- **kwargs
Additional parameters that will be passed to
three_d_animate
function.
- spateo.plotting.static.three_d_plot.pairwise_iteration_panel(adataA: anndata.AnnData, adataB: anndata.AnnData, layer: str = 'X', group_key: str | list = None, select_group: str | list = None, spatial_key: str = 'align_spatial', iter_key: str = 'iter_spatial', filename: str = 'animate.mp4', jupyter: bool | Literal['none', 'static', 'trame'] = False, off_screen: bool = False, id_key: str | None = None, cpo: str | list | None = None, window_size: tuple | None = None, background: str = 'black', modelA_cmap: str = 'dodgerblue', modelB_cmap: str = 'red', ambient: int | float = 0.3, modelA_opacity: int | float = 0.8, modelB_opacity: int | float = 1.0, model_size: float | list = 6.0, show_axes: bool = True, show_legend: bool = True, legend_kwargs: dict | None = None, text: bool | str = True, text_kwargs: dict | None = None, framerate: int = 6, **kwargs)[source]¶
- spateo.plotting.static.three_d_plot.pairwise_mapping(idA: str = 'sampleA', idB: str = 'sampleB', adataA: anndata.AnnData | None = None, adataB: anndata.AnnData | None = None, pi: numpy.ndarray | None = None, modelA: pyvista.PolyData | None = None, modelB: pyvista.PolyData | None = None, model_lines: pyvista.PolyData | None = None, layer: str = 'X', group_key: str | list = None, spatial_key: str = 'align_spatial', keep_all: bool = False, distance: int | float | None = 300, direction: Literal['x', 'y', 'z'] | None = 'z', filename: str | None = None, jupyter: bool | Literal['none', 'static', 'trame'] = False, off_screen: bool = False, cpo: str | list | None = 'iso', window_size: tuple | None = (1024, 1024), background: str = 'black', modelA_cmap: str = 'dodgerblue', modelA_amap: float | list = 1.0, modelB_cmap: str = 'red', modelB_amap: float | list = 1.0, line_color: str = 'gainsboro', line_alpha: float | list = 1.0, ambient: float = 0.3, model_opacity: float = 1, line_opacity: float = 0.03, model_size: float | list = 6.0, line_size: float | list = 2.0, show_axes: bool = True, show_legend: bool = True, legend_kwargs: dict | None = None, text: bool | str = True, text_kwargs: dict | None = None, **kwargs)[source]¶
Visualize the pairing of cells between two models.
- Parameters:
- idA
ID of modelA.
- idB
ID of modelB.
- adataA
Anndata object of modelA.
- adataB
Anndata object of modelB.
- pi
The pi matrix obtained by alignment.
- modelA
The point cloud model of adataA.
- modelB
The point cloud model of adataB.
- model_lines
Cell connection lines between modelA and modelB
- layer
If
'X'
, uses.X
, otherwise uses the representation given by.layers[layer]
.- group_key
The key that stores clustering or annotation information in
.obs
, a gene name or a list of gene names in.var
.- spatial_key
The key in
.obsm
that corresponds to the spatial coordinate of each bucket.- keep_all
Whether to retain all the optimal relationships obtained only based on the pi matrix, If
keep_all
is False, the optimal relationships obtained based on the pi matrix and the nearest coordinates.- distance
Distance between modelA and modelB when visualizing.
- direction
The direction between modelA and modelB when visualizing.
- 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'
. Whenjupyter=False
, if you want to save ‘.png’ file, please ensureoff_screen=True
.
- 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.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- cpo
Camera position of the active render window. Available
cpo
are:- Iterable containing position, focal_point, and view up.
E.g.: [(2.0, 5.0, 13.0), (0.0, 0.0, 0.0), (-0.7, -0.5, 0.3)].
- Iterable containing a view vector.
E.g.: [-1.0, 2.0, -5.0].
- A string containing the plane orthogonal to the view direction.
E.g.: 'xy', 'xz', 'yz', 'yx', 'zx', 'zy', 'iso'.
- window_size
Window size in pixels. The default window_size is
(1024, 1024)
.- background
The background color of the window.
- modelA_cmap
Colors to use for plotting modelA. The default colormap is
'dodgerblue'
.- modelA_amap
The opacity of the colors to use for plotting modelA. The default alphamap is
1.0
.- modelB_cmap
Colors to use for plotting modelB. The default colormap is
'red'
.- modelB_amap
The opacity of the colors to use for plotting modelB. The default alphamap is
1.0
.- line_color
Colors to use for plotting lines. The default colormap is
'gainsboro'
.- line_alpha
Alpha to use for plotting lines. The default colormap is
'gainsboro'
.- 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.
- model_opacity
Opacity of the modelA and modelB.
- line_opacity
Opacity of the lines.
- model_size
The point size of any nodes in the dataset plotted.
- line_size
The line size of lines in the dataset plotted.
- show_axes
Whether to add a camera orientation widget to the active renderer.
- show_legend
whether to add a legend to the plotter.
- legend_kwargs
A dictionary that will be pass to the
add_legend
function.By default, it is an empty dictionary and the
add_legend
function will use the{"legend_size": None, "legend_loc": None, "legend_size": None, "legend_loc": None, "title_font_size": None, "label_font_size": None, "font_family": "arial", "fmt": "%.2e", "n_labels": 5, "vertical": True}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- text
The text to add the rendering.
- text_kwargs
A dictionary that will be pass to the
add_text
function.By default, it is an empty dictionary and the
add_legend
function will use the{ "font_family": "arial", "font_size": 12, "font_color": "black", "text_loc": "upper_left"}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- **kwargs
Additional parameters that will be passed to
three_d_plot
function.
- Returns:
The point cloud models of adataA. pcB: The point cloud models of adataB. model_lines: Cell mapping lines between modelA and modelB.
- Return type:
pcA
- spateo.plotting.static.three_d_plot.pi_heatmap(pi: numpy.ndarray, model1_name: str = 'model1', model2_name: str = 'model2', colormap: str = 'hot_r', fig_height: int | float = 3, robust: bool = False, vmin: int | float | None = None, vmax: int | float | None = None, fontsize: int | float = 12, filename: str | None = None, **kwargs)[source]¶
Visualize a heatmap of the pi matrix.
- Parameters:
- pi
The pi matrix obtained by alignment.
- model1_name
The name/id of model1.
- model2_name
The name/id of model2.
- colormap
Colors to use for plotting heatmap. The default colormap is
'hot_r'
.- fig_height
Figure height.
- robust
If True and vmin or vmax are absent, the colormap range is computed with robust quantiles instead of the extreme values.
- vmin
Values to anchor the colormap, otherwise they are inferred from the data and other keyword arguments.
- vmax
Values to anchor the colormap, otherwise they are inferred from the data and other keyword arguments.
- fontsize
The font size of x label and y label.
- filename
Filename of output file.
- **kwargs
Additional parameters that will be passed to
sns.heatmap
function.
- spateo.plotting.static.three_d_plot.merge_animations(mp4_files: list | None = None, mp4_folder: list | None = None, filename: str = 'merged_animation.mp4')[source]¶
Use MoviePy to compose a new animation and play multiple animations together in the new animation.
- Parameters:
- mp4_files
A list containing absolute paths to mp4 files that need to be played together.
- mp4_folder
Absolute path to the folder containing all mp4 files that need to be played together. If
mp4_files
is provided,mp4_folder
cannot also be provided.- filename
Absolute path to save the newly composed animation.
Examples
st.pl.merge_animations(mp4_files=[“animation1.mp4”, “animation2.mp4”], filename=f”merged_animation.mp4”)
- spateo.plotting.static.three_d_plot.three_d_animate(models: Union[List[PolyData or UnstructuredGrid], pyvista.MultiBlock], stable_model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock | None = None, stable_kwargs: dict | None = None, key: str | None = None, filename: str = 'animate.mp4', jupyter: bool | Literal['panel', 'none', 'pythreejs', 'static', 'ipygany', 'html'] = False, off_screen: bool = False, window_size: tuple = (512, 512), background: str = 'white', cpo: str | list = 'iso', colormap: str | list | None = None, ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, model_style: Literal['points', 'surface', 'wireframe'] | list = 'surface', model_size: float | list = 3.0, show_legend: bool = True, legend_kwargs: dict | None = None, show_outline: bool = False, outline_kwargs: dict | None = None, text: str | None = None, text_kwargs: dict | None = None, framerate: int = 24, plotter_filename: str | None = None)[source]¶
Animated visualization of 3D reconstruction model.
- Parameters:
- models
A List of reconstructed models or a MultiBlock.
- stable_model
The model that do not change with time in animation.
- stable_kwargs
Parameters for plotting stable model. Available
stable_kwargs
are:'key'
'ambient'
'opacity'
'model_style'
'model_size'
'background'
'show_legend'
'legend_kwargs'
'show_outline'
'outline_kwargs'
'text'
'text_kwargs'
- key
The key under which are the labels.
- filename
Filename of output file. Writer type is inferred from the extension of the filename.
Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- jupyter
Whether to plot in jupyter notebook. Available
jupyter
are:'none'
- Do not display in the notebook.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- window_size
Window size in pixels. The default window_size is
[512, 512]
.- background
The background color of the window.
- cpo
Camera position of the active render window. Available
cpo
are:- Iterable containing position, focal_point, and view up.
E.g.: [(2.0, 5.0, 13.0), (0.0, 0.0, 0.0), (-0.7, -0.5, 0.3)].
- Iterable containing a view vector.
E.g.: [-1.0, 2.0, -5.0].
- A string containing the plane orthogonal to the view direction.
E.g.: 'xy', 'xz', 'yz', 'yx', 'zx', 'zy', 'iso'.
- 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.- show_legend
whether to add a legend to the plotter.
- legend_kwargs
A dictionary that will be pass to the
add_legend
function. By default, it is an empty dictionary and theadd_legend
function will use the{"legend_size": None, "legend_loc": None, "legend_size": None, "legend_loc": None, "title_font_size": None, "label_font_size": None, "font_family": "arial", "fmt": "%.2e", "n_labels": 5, "vertical": True}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- show_outline
whether to produce an outline of the full extent for the model.
- outline_kwargs
A dictionary that will be pass to the
add_outline
function.By default, it is an empty dictionary and the add_legend function will use the
{"outline_width": 5.0, "outline_color": "black", "show_labels": True, "font_size": 16, "font_color": "white", "font_family": "arial"}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- text
The text to add the rendering.
- text_kwargs
A dictionary that will be pass to the
add_text
function.By default, it is an empty dictionary and the
add_legend
function will use the{ "font_family": "arial", "font_size": 12, "font_color": "black", "text_loc": "upper_left"}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- framerate
Frames per second. Only available when filename ending with
.mp4
or.gif
.- plotter_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.
- spateo.plotting.static.three_d_plot.three_d_multi_plot(model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock, key: str | list = None, filename: str | None = None, jupyter: bool | Literal['panel', 'none', 'pythreejs', 'static', 'ipygany', 'html'] = False, off_screen: bool = False, shape: str | list | tuple = None, window_size: tuple | None = None, background: str = 'white', cpo: str | list = 'iso', colormap: str | list | None = None, ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, model_style: Literal['points', 'surface', 'wireframe'] | list = 'surface', model_size: float | list = 3.0, show_legend: bool = True, legend_kwargs: dict | None = None, show_outline: bool = False, outline_kwargs: dict | None = None, text: str | list = None, text_kwargs: dict | None = None, view_up: tuple = (0.5, 0.5, 1), framerate: int = 24, plotter_filename: str | None = None)[source]¶
Multi-view visualization of reconstructed 3D model. If you want to draw a legend in each sub-window, please ensure that the key names used in each legend are different.
- Parameters:
- model
A MultiBlock of reconstructed models or a reconstructed model.
- key
The key under which are the labels.
- 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'
.Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- jupyter
Whether to plot in jupyter notebook. Available
jupyter
are:'none'
- Do not display in the notebook.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- shape
Number of sub-render windows inside the main window. By default, there is only one render window.
- window_size
Window size in pixels. The default window_size is
[512, 512]
.- background
The background color of the window.
- cpo
Camera position of the active render window. Available
cpo
are:- Iterable containing position, focal_point, and view up.
E.g.: [(2.0, 5.0, 13.0), (0.0, 0.0, 0.0), (-0.7, -0.5, 0.3)].
- Iterable containing a view vector.
E.g.: [-1.0, 2.0, -5.0].
- A string containing the plane orthogonal to the view direction.
E.g.: 'xy', 'xz', 'yz', 'yx', 'zx', 'zy', 'iso'.
- 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.- show_legend
whether to add a legend to the plotter.
- legend_kwargs
A dictionary that will be pass to the
add_legend
function. By default, it is an empty dictionary and theadd_legend
function will use the{"legend_size": None, "legend_loc": None, "legend_size": None, "legend_loc": None, "title_font_size": None, "label_font_size": None, "font_family": "arial", "fmt": "%.2e", "n_labels": 5, "vertical": True}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- show_outline
whether to produce an outline of the full extent for the model.
- outline_kwargs
A dictionary that will be pass to the
add_outline
function.By default, it is an empty dictionary and the add_legend function will use the
{"outline_width": 5.0, "outline_color": "black", "show_labels": True, "font_size": 16, "font_color": "white", "font_family": "arial"}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- text
The text to add the rendering.
- text_kwargs
A dictionary that will be pass to the
add_text
function.By default, it is an empty dictionary and the
add_legend
function will use the{ "font_family": "arial", "font_size": 12, "font_color": "black", "text_loc": "upper_left"}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- 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
.- plotter_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.
- spateo.plotting.static.three_d_plot.three_d_plot(model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.MultiBlock, key: str | list = None, filename: str | None = None, jupyter: bool | Literal['panel', 'none', 'pythreejs', 'static', 'ipygany', 'html'] = False, off_screen: bool = False, window_size: tuple = (512, 512), background: str = 'white', cpo: str | list = 'iso', colormap: str | list | None = None, ambient: float | list = 0.2, opacity: float | numpy.ndarray | list = 1.0, model_style: Literal['points', 'surface', 'wireframe'] | list = 'surface', model_size: float | list = 3.0, show_legend: bool = True, legend_kwargs: dict | None = None, show_outline: bool = False, outline_kwargs: dict | None = None, text: str | None = None, text_kwargs: dict | None = None, view_up: tuple = (0.5, 0.5, 1), framerate: int = 24, plotter_filename: str | None = None, show_axes: bool = False)[source]¶
Visualize reconstructed 3D model.
- Parameters:
- model
A reconstructed model.
- key
The key under which are the labels.
- 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'
.Output a gif file, please enter a filename ending with
.gif
.Output a mp4 file, please enter a filename ending with
.mp4
.
- jupyter
Whether to plot in jupyter notebook. Available
jupyter
are:'none'
- Do not display in the notebook.'pythreejs'
- Show a pythreejs widget'static'
- Display a static figure.'ipygany'
- Show an ipygany widget'panel'
- Show a panel widget.
- off_screen
Renders off-screen when True. Useful for automated screenshots.
- window_size
Window size in pixels. The default window_size is
[512, 512]
.- background
The background color of the window.
- cpo
Camera position of the active render window. Available
cpo
are:- Iterable containing position, focal_point, and view up.
E.g.: [(2.0, 5.0, 13.0), (0.0, 0.0, 0.0), (-0.7, -0.5, 0.3)].
- Iterable containing a view vector.
E.g.: [-1.0, 2.0, -5.0].
- A string containing the plane orthogonal to the view direction.
E.g.: 'xy', 'xz', 'yz', 'yx', 'zx', 'zy', 'iso'.
- 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.- show_legend
whether to add a legend to the plotter.
- legend_kwargs
A dictionary that will be pass to the
add_legend
function. By default, it is an empty dictionary and theadd_legend
function will use the{"legend_size": None, "legend_loc": None, "legend_size": None, "legend_loc": None, "title_font_size": None, "label_font_size": None, "font_family": "arial", "fmt": "%.2e", "n_labels": 5, "vertical": True}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- show_outline
whether to produce an outline of the full extent for the model.
- outline_kwargs
A dictionary that will be pass to the
add_outline
function.By default, it is an empty dictionary and the add_legend function will use the
{"outline_width": 5.0, "outline_color": "black", "show_labels": True, "font_size": 16, "font_color": "white", "font_family": "arial"}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- text
The text to add the rendering.
- text_kwargs
A dictionary that will be pass to the
add_text
function.By default, it is an empty dictionary and the
add_legend
function will use the{ "font_family": "arial", "font_size": 12, "font_color": "black", "text_loc": "upper_left"}
as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.- 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
.- plotter_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.
- 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