pysdic.ImagePlotter.add_mesh#

ImagePlotter.add_mesh(mesh, *, projected=None, warp_by=None, vertex_color='black', vertex_size=5.0, vertex_opacity=1.0, vertex_mask=None, show_vertices=True, edge_color='black', edge_width=1.0, edge_opacity=1.0, show_edges=True, face_color='lightblue', face_opacity=0.5, 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, show_bar=False, bar=None, vertex_vectors=None, element_vectors=None, vector_scale=1.0, vector_color='red', show_vertices_index=False, show_elements_index=False, vertex_index_color='black', element_index_color='blue', index_font_size=8)[source]#

Add a mesh to the plotter (projected or drawn in image points, see pysdic.ImagePlotter).

The element type of the mesh must be set. The faces are the polygons through the nodes of the contour of the elements (corner and mid-edge nodes). The segment elements are drawn as edges only (no faces). The faces are displayed if they are selected by face_mask and all their vertices are finite (after projection). The vertices are displayed if they are selected by vertex_mask and finite.

Parameters:
  • mesh (pysdic.Mesh) – The mesh to display.

  • projected (Optional[bool], optional) – Whether to project the vertices with the camera (see pysdic.ImagePlotter). By default, chosen with the dimension of the vertices.

  • warp_by (Optional[Union[str, ArrayLike]], optional) – The displacement added to the vertices before the projection: the name of a vertex property or an array, of shape \((N_v, E)\).

  • vertex_color (str | Tuple[Real, ...]) – The color, size (strictly positive) and opacity (in \([0, 1]\)) of the vertices.

  • vertex_size (Real) – The color, size (strictly positive) and opacity (in \([0, 1]\)) of the vertices.

  • vertex_opacity (Real) – The color, size (strictly positive) and opacity (in \([0, 1]\)) of the vertices.

  • vertex_mask (Optional[ArrayLike], optional) – A boolean array of shape \((N_v,)\), True for the vertices to display. The faces are not affected.

  • show_vertices (bool, optional (default: True)) – Whether to show the vertices.

  • edge_color (str | Tuple[Real, ...]) – The color, width (strictly positive) and opacity (in \([0, 1]\)) of the edges.

  • edge_width (Real) – The color, width (strictly positive) and opacity (in \([0, 1]\)) of the edges.

  • edge_opacity (Real) – The color, width (strictly positive) and opacity (in \([0, 1]\)) of the edges.

  • show_edges (bool, optional (default: True)) – Whether to show the edges of the displayed faces.

  • face_color (Union[str, Tuple[Real, …]], optional (default: "lightblue")) – The color of the faces. Ignored if a property is given.

  • face_opacity (Real, optional (default: 0.5)) – The opacity of the faces, in \([0, 1]\).

  • face_mask (Optional[ArrayLike], optional) – A boolean array of shape \((N_e,)\), True for the faces to display.

  • show_faces (bool, optional (default: True)) – Whether to show the faces.

  • vertex_property (Optional[Union[str, ArrayLike]], optional) – The property used to color the faces (interpolated between the nodes of the contour): the name of a vertex property, or an array of shape \((N_v,)\) or \((N_v, A)\).

  • element_property (Optional[Union[str, ArrayLike]], optional) – The property used to color the faces (one color per face): the name of an element property, or an array of shape \((N_e,)\) or \((N_e, A)\). Only one of vertex_property and element_property can be given.

  • property_axis (Integral | None) – See add_point_cloud().

  • property_clim (Tuple[Real, Real] | None) – See add_point_cloud().

  • property_cmap (str | Colormap | None) – See add_point_cloud().

  • property_below_color (str | Tuple[Real, ...] | None) – See add_point_cloud().

  • property_above_color (str | Tuple[Real, ...] | None) – See add_point_cloud().

  • show_bar (bool) – See add_point_cloud().

  • bar (Dict[str, Any] | None) – See add_point_cloud().

  • vertex_vectors (Optional[Union[str, ArrayLike]], optional) – A vector field in the image plane drawn as arrows from the vertices selected by vertex_mask: the name of a vertex property or an array of shape \((N_v, 2)\).

  • element_vectors (Optional[Union[str, ArrayLike]], optional) – A vector field in the image plane drawn as arrows from the (projected) centers of the elements selected by face_mask (see pysdic.Mesh.compute_elements_centers()): the name of an element property or an array of shape \((N_e, 2)\). Only one of vertex_vectors and element_vectors can be given.

  • vector_scale (Union[Real, ArrayLike], optional (default: 1.0)) – The scale factor of the arrows: a scalar or a 1D array with one value per row of the vector field (\(N_v\) or \(N_e\)).

  • vector_color (Union[str, Tuple[Real, …]], optional (default: "red")) – The color of the arrows.

  • show_vertices_index (bool, optional (default: False)) – Whether to write the index of each vertex selected by vertex_mask next to it (even if show_vertices is False).

  • show_elements_index (bool, optional (default: False)) – Whether to write the index of each element selected by face_mask at its (projected) center (see pysdic.Mesh.compute_elements_centers()), even if show_faces is False.

  • vertex_index_color (Union[str, Tuple[Real, …]], optional (default: "black")) – The color of the indices of the vertices.

  • element_index_color (Union[str, Tuple[Real, …]], optional (default: "blue")) – The color of the indices of the elements.

  • index_font_size (Real, optional (default: 8)) – The font size of the indices in typographic points (strictly positive): the labels keep their size when zooming.

Raises:
  • TypeError – If mesh is not a pysdic.Mesh.

  • ValueError – If the mesh is empty or has no element type, if the vertices cannot be projected or drawn, if an input has a wrong shape, or if nothing can be displayed.

  • IndexError – If property_axis is out of range.

Return type:

None