pysdic.Mesh.visualize#
- Mesh.visualize(vertex_color=None, vertex_size=None, vertex_opacity=None, vertex_mask=None, show_vertices=True, edge_color=None, edge_width=None, edge_opacity=None, show_edges=True, face_color=None, face_opacity=None, face_mask=None, show_faces=True, vertex_property=None, element_property=None, property_axis=None, property_clim=None, property_cmap=None, property_below_color=None, property_above_color=None, texture=None, texture_rgb=True, additional_points=None, additional_points_color=None, additional_points_size=None, additional_points_opacity=None, bar_title=None, bar_width=None, bar_height=None, bar_position_x=None, bar_position_y=None, bar_title_font_family=None, bar_title_font_size=None, bar_label_font_size=None, bar_title_color=None, bar_title_bold=False, bar_vertical=True, bar_interactive=False, show_bar=True, title=None, title_color=None, title_font_family=None, title_font_size=None, show_title=True, bounds=None, bounds_grid=None, bounds_ticks=None, bounds_location=None, bounds_color=None, bounds_font_size=None, bounds_font_family=None, bounds_bold=False, bounds_fmt=None, bounds_title_x='X Axis', bounds_title_y='Y Axis', bounds_title_z='Z Axis', bounds_n_xlabels=5, bounds_n_ylabels=5, bounds_n_zlabels=5, bounds_show_xaxis=True, bounds_show_yaxis=True, bounds_show_zaxis=True, bounds_show_xlabels=True, bounds_show_ylabels=True, bounds_show_zlabels=True, show_bounds=True, camera_position=None, camera_focal_point=None, camera_view_up=None, screenshot_path=None)[source]#
Visualize the mesh using PyVista (only for \(E \leq 3\) embbeded dimension), the mesh must have
element_typeset.Note
For 1D or 2D vertices clouds, the vertices are visualized in a 3D space by adding zero coordinates for the missing dimensions.
See also
PyVista Documentation for more details on visualization options.
- Parameters:
vertex_color (Union[
str, Tuple[Real, Real, Real]], optional) – The color of the vertices in the visualization. Can be a string representing a color name (e.g.,"red"), or an RGB tuple or hex string.vertex_size (Real, optional) – The size of the vertices in the visualization. Must be a positive value if provided. Default is set by PyVista to
5.0.vertex_opacity (Real, optional) – The opacity of the vertices in the visualization. Must be between
0.0(fully transparent) and1.0(fully opaque) if provided. Default is set by PyVista to1.0.vertex_mask (ArrayLike, optional) – A boolean array of shape \((N_v,)\) where \(N_v\) is the number of vertices in the mesh, indicating which vertices to show (True) or hide (False) in the visualization.
show_vertices (
bool, optional) – Whether to show the vertices in the visualization. Default isTrue.edge_color (Union[
str, Tuple[Real, Real, Real]], optional) – The color of the edges in the visualization. Can be a string representing a color name (e.g.,"black"), or an RGB tuple or hex string.edge_width (Real, optional) – The width of the edges in the visualization. Must be a positive value if provided.
edge_opacity (Real, optional) – The opacity of the edges in the visualization. Must be between
0.0(fully transparent) and1.0(fully opaque) if provided.show_edges (
bool, optional) – Whether to show the edges in the visualization. Default isTrue.face_color (Union[
str, Tuple[Real, Real, Real]], optional) – The color of the faces in the visualization. Can be a string representing a color name (e.g.,"lightgray"), or an RGB tuple or hex string. This parameter is ignored ifvertex_propertyorelement_propertyis provided.face_opacity (Real, optional) – The opacity of the faces in the visualization. Must be between
0.0(fully transparent) and1.0(fully opaque) if provided.face_mask (ArrayLike, optional) – A boolean array of shape \((N_e,)\) where \(N_e\) is the number of elements in the mesh, indicating which faces to show (True) or hide (False) in the visualization.
show_faces (
bool, optional) – Whether to show the faces in the visualization. Default isTrue.vertex_property (Union[
str, ArrayLike], optional) – The property to use for coloring the mesh based on a vertex property. Can be a string representing the property key of a property stored in the point cloud, or a NumPy array of shape \((N_p,)\) or \((N_p, A)\) representing a property to use for coloring the vertices. Note that if a string key is provided, the corresponding property must exist in the point cloud.element_property (Union[
str, ArrayLike], optional) – The property to use for coloring the mesh based on an element property. Can be a string representing the property key of a property stored in the connectivity, or a NumPy array of shape \((N_e,)\) or \((N_e, A)\) representing a property to use for coloring the elements. Note that if a string key is provided, the corresponding property must exist in the connectivity.property_axis (Optional[Integral], optional) – The axis to use when
propertycontains multiple attributes per vertex (shape \((N_p, A)\)). IfNone, the magnitude of the property vector is used for coloring. By default,None.property_clim (Optional[Tuple[Real, Real]], optional) – The color limits (min, max) for the property values when
propertyis provided. IfNone, the color limits are determined automatically. Default isNone.property_cmap (Union[
str,matplotlib.colors.Colormap], optional) – The colormap to use for coloring the points based on the property values. Can be a string representing a Matplotlib colormap or a Matplotlib Colormap object. IfNone, the default colormap"viridis"is used by Matplotlib.property_below_color (Union[
str, Tuple[Real, Real, Real]], optional) – The color to use for points with property values below the minimum color limit whenproperty_climis provided. Can be a string representing a color name (e.g.,"blue"), or an RGB tuple or hex string. IfNone, the default below color is set to the minimum color of the colormap.property_above_color (Union[
str, Tuple[Real, Real, Real]], optional) – The color to use for points with property values above the maximum color limit whenproperty_climis provided. Can be a string representing a color name (e.g.,"red"), or an RGB tuple or hex string. IfNone, the default above color is set to the maximum color of the colormap.texture (Optional[ArrayLike], optional) – A numpy array representing a texture to apply to the mesh. The shape and format of the texture array should be compatible with PyVista’s texture mapping requirements. The
uvmapmust be set for the mesh connectivity.texture_rgb (
bool, optional) – IfTrue, the texture is interpreted as an RGB image. IfFalse, the texture is interpreted as a single-channel scalar field. Default isTrue.additional_points (Optional[Union[ArrayLike,
PointCloud,IntegrationPoints]], optional) – A numpy array of shape (\(N_{ap}\), 3) containing the coordinates of additional points to visualize alongside the mesh. The additional points are visualized as spheres in the visualization. If provides as aPointCloudorIntegrationPoints, the coordinates of the points will be extracted from thepointsattribute of the object or compute by interpolating the vertices coordinates at the integration points, respectively.additional_points_color (Union[
str, Tuple[Real, Real, Real]], optional) – The color of the additional points in the visualization. Can be a string representing a color name (e.g.,"green"), or an RGB tuple or hex string.additional_points_size (Optional[Real], optional) – The size of the additional points in the visualization. Must be a positive value if provided.
additional_points_opacity (Optional[Real], optional) – The opacity of the additional points in the visualization. Must be between
0.0(fully transparent) and1.0(fully opaque) if provided.bar_title (Optional[
str], optional) – The title of the color bar whenpropertyis provided. IfNone, no title is displayed.bar_width (Optional[Real], optional) – The width of the color bar as a fraction of the window width. Must be between
0.0and1.0if provided.bar_height (Optional[Real], optional) – The height of the color bar as a fraction of the window height. Must be between
0.0and1.0if provided.bar_position_x (Optional[Real], optional) – The x position of the color bar as a fraction of the window width. Must be between
0.0and1.0if provided.bar_position_y (Optional[Real], optional) – The y position of the color bar as a fraction of the window height. Must be between
0.0and1.0if provided.bar_title_font_family (Optional[
str], optional) – The font type of the color bar title between"arial","courier", and"times".bar_title_font_size (Optional[Integral], optional) – The font size of the color bar title.
bar_label_font_size (Optional[Integral], optional) – The font size of the color bar labels.
bar_title_color (Union[
str, Tuple[Real, Real, Real]], optional) – The color of the color bar title text. Can be a string representing a color name (e.g.,"black"), or an RGB tuple or hex string.bar_title_bold (
bool, optional) – Whether to display the color bar title in bold font. Default isFalse.bar_vertical (
bool, optional) – Whether to display the color bar vertically. IfFalse, the color bar is displayed horizontally. Default isTrue.bar_interactive (
bool, optional) – IfTrue, enables interactive mode for the color bar in PyVista. Default isFalse.show_bar (
bool, optional) – Whether to show the color bar in the visualization. Default isTrue.title (Optional[
str], optional) – The title of the visualization window.title_color (Union[
str, Tuple[Real, Real, Real]], optional) – The color of the title text. Can be a string representing a color name (e.g.,"blue"), or an RGB tuple or hex string.title_font_family (Optional[
str], optional) – The font type of the title between"arial","courier", and"times".title_font_size (Optional[Integral], optional) – The font size of the title.
show_title (
bool, optional) – Whether to show the title in the visualization. Default isTrue.bounds (Optional[Tuple[Real, Real, Real, Real, Real, Real]], optional) – The bounds of the axes in the format (
min_x,max_x,min_y,max_y,min_z,max_z). IfNone, the bounds are determined automatically.bounds_grid (Optional[
str], optional) – Add grid lines to the backface (True, ‘back’, or ‘backface’) or to the frontface (‘front’, ‘frontface’) of the axes actor.bounds_ticks (Optional[
str], optional) – Set how the ticks are drawn on the axes grid. Options include: ‘inside’, ‘outside’, ‘both’.bounds_location (Optional[
str], optional) – Set how the axes are drawn: either static (‘all’), closest triad (‘front’, ‘closest’, ‘default’), furthest triad (‘back’, ‘furthest’), static closest to the origin (‘origin’), or outer edges (‘outer’) in relation to the camera position.bounds_color (Union[
str, Tuple[Real, Real, Real]], optional) – The color of the axes bounds. Can be a string representing a color name (e.g.,"black"), or an RGB tuple or hex string.bounds_font_size (Optional[Integral], optional) – The font size of the axes bounds.
bounds_font_family (Optional[
str], optional) – The font type of the axes bounds between"arial","courier", and"times".bounds_bold (
bool, optional) – Whether to display the axes bounds in bold font. Default isFalse.bounds_fmt (Optional[
str], optional) – The format string for the axes bounds labels (e.g.,"{:.2f}"for 2 decimal places).bounds_title_x (
str, optional) – The title for the x-axis bounds. Default is"X Axis".bounds_title_y (
str, optional) – The title for the y-axis bounds. Default is"Y Axis".bounds_title_z (
str, optional) – The title for the z-axis bounds. Default is"Z Axis".bounds_n_xlabels (Integral, optional) – The number of labels to display on the x-axis bounds. Default is
5.bounds_n_ylabels (Integral, optional) – The number of labels to display on the y-axis bounds. Default is
5.bounds_n_zlabels (Integral, optional) – The number of labels to display on the z-axis bounds. Default is
5.bounds_show_xaxis (
bool, optional) – Whether to show the x-axis in the bounds. Default isTrue.bounds_show_yaxis (
bool, optional) – Whether to show the y-axis in the bounds. Default isTrue.bounds_show_zaxis (
bool, optional) – Whether to show the z-axis in the bounds. Default isTrue.bounds_show_xlabels (
bool, optional) – Whether to show the x-axis labels in the bounds. Default isTrue.bounds_show_ylabels (
bool, optional) – Whether to show the y-axis labels in the bounds. Default isTrue.bounds_show_zlabels (
bool, optional) – Whether to show the z-axis labels in the bounds. Default isTrue.show_bounds (
bool, optional) – Whether to show the axes bounds in the visualization. Default isTrue.camera_position (Optional[ArrayLike], optional) – The position of the camera in the 3D space as a NumPy array of shape \((3,)\).
camera_focal_point (Optional[ArrayLike], optional) – The focal point of the camera in the 3D space as a NumPy array of shape \((3,)\).
camera_view_up (Optional[ArrayLike], optional) – The view up vector of the camera as a NumPy array of shape \((3,)\).
screenshot_path (Optional[
str], optional) – The file path to save a screenshot of the visualization. IfNone, no screenshot is saved.
- Return type:
None
Examples
Create a simple
Meshinstance and visualize it.import numpy as np from pysdic import Mesh points = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]]) connectivity = np.array([[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]]) mesh3d = Mesh(points, connectivity, element_type="triangle_3") mesh3d.visualize( vertex_color="red", edge_color="black", face_color="lightgray", vertex_size=10.0, edge_width=2.0, face_opacity=0.5, show_vertices=True, show_edges=True, show_faces=True, title="3D Mesh Visualization", title_color="blue", title_font_size=16, )