ogstools.meshplotlib package#

meshplotlib utilities for simple access.

ogstools.meshplotlib.plot(meshes, mesh_property, fig=None, ax=None)[source]#

Plot the property field of meshes with default settings.

The resulting figure adheres to the configurations in meshplotlib.setup. For 2D, the whole domain, for 3D a set of slices is displayed.

Parameters:
  • meshes (list[UnstructuredGrid] | ndarray | UnstructuredGrid) – Singular mesh of 2D numpy array of meshes

  • property – The property field to be visualized on all meshes

  • fig (Figure | None) – Matplotlib Figure object to use for plotting (optional)

  • ax (Axes | None) – Matplotlib Axis object to use for plotting (optional)

  • mesh_property (Property | str)

Return type:

Figure | None

ogstools.meshplotlib.plot_contour(ax, mesh, style, lw, projection=2)[source]#
Parameters:
  • ax (Axes)

  • mesh (DataSet)

  • style (str)

  • lw (int)

  • projection (int)

Return type:

None

ogstools.meshplotlib.plot_on_top(ax, surf, contour, scaling=1.0)[source]#
Parameters:
  • ax (Axes)

  • surf (DataSet)

  • contour (Callable[[ndarray], ndarray])

  • scaling (float)

Return type:

None

ogstools.meshplotlib.plot_probe(mesh_series, points, mesh_property, mesh_property_abscissa=None, labels=None, time_unit='s', interp_method=None, interp_backend_pvd=None, colors=None, linestyles=None, ax=None, fill_between=False, **kwargs)[source]#

Plot the transient property on the observation points in the MeshSeries.

param mesh_series:

MeshSeries object containing the data to be plotted.

param points:

The points to sample at.

param mesh_property:

The property to be sampled.

param labels:

The labels for each observation point.

param time_unit:

Output unit of the timevalues.

param interp_method:

Choose the interpolation method, defaults to linear for xdmf MeshSeries and probefilter for pvd MeshSeries.

param interp_backend:

Interpolation backend for PVD MeshSeries.

param kwargs:

Keyword arguments passed to matplotlib’s plot function.

returns:

A matplotlib Figure

Parameters:
  • mesh_series (MeshSeries)

  • points (ndarray)

  • mesh_property (Property | str)

  • mesh_property_abscissa (Property | str | None)

  • labels (list[str] | None)

  • time_unit (str | None)

  • interp_method (Literal['nearest', 'linear', 'probefilter'] | None)

  • interp_backend_pvd (Literal['vtk', 'scipy'] | None)

  • colors (list | None)

  • linestyles (list | None)

  • ax (Axes | None)

  • fill_between (bool)

  • kwargs (Any)

Return type:

Figure | None

ogstools.meshplotlib.subplot(mesh, mesh_property, ax, levels=None)[source]#

Plot the property field of a mesh on a matplotlib.axis.

In 3D the mesh gets sliced according to slice_type and the origin in the PlotSetup in meshplotlib.setup. Custom levels and a colormap string can be provided.

Parameters:
  • mesh (UnstructuredGrid)

  • mesh_property (Property | str)

  • ax (Axes)

  • levels (ndarray | None)

Return type:

None

ogstools.meshplotlib.update_font_sizes(fontsize=20, label_axes='both', fig=None, ax=None)[source]#

Update font sizes of labels and ticks in all subplots

Parameters:
  • fig (Figure | None) – Matplotlib Figure object to use for plotting

  • fontsize (int) – New font size for the labels and ticks (optional)

  • label_axes (str) – Apply labels to axis: “x”, “y”, “both”, “none”

  • ax (axes | None)

Return type:

Figure

ogstools.meshplotlib.label_spatial_axes(axes, x_label='x', y_label='y', label_axes='both', fontsize=20)[source]#

Add labels to x and y axis.

If given an array of axes, only the outer axes will be labeled.

Parameters:
  • axes (Axes | ndarray)

  • x_label (str)

  • y_label (str)

  • label_axes (str)

  • fontsize (int)

Return type:

None

ogstools.meshplotlib.clear_labels(axes)[source]#
Parameters:

axes (Axes | ndarray)

Return type:

None

ogstools.meshplotlib.plot_profile(mesh, properties, profile_points, profile_plane=(0, 1), resolution=None, plot_nodal_pts=True, nodal_pts_labels=None)[source]#

Default plot for the data obtained from sampling along a profile on a mesh.

Parameters:
  • mesh (UnstructuredGrid) – Mesh providing the data

  • props – Properties to be read from the mesh

  • profile_points (ndarray) – Points defining the profile (and its segments)

  • resolution (int | None) – Resolution of the sampled profile. Total number of points within all profile segments.

  • plot_nodal_pts (bool | None) – Plot and annotate all nodal points in profile

  • nodal_pts_labels (str | list | None) – Labels for nodal points (only use if plot_nodal_points is set to True)

  • twinx – Enable plotting second property on twin-x axis (only works if exactly two properties are provided in props param)

  • profile_plane (tuple | list) – Define which coordinates to use if profile plane is different than XY: [0, 2] for XZ, [1, 2] for YZ…

  • properties (str | list | Property)

Returns:

Tuple containing Matplotlib Figure and Axis objects

Return type:

tuple[Figure, Axes]

ogstools.meshplotlib.lineplot(x, y, mesh, profile_points, ax=None, fontsize=20, twinx=False, resolution=100)[source]#

Plot selected properties obtained from sample_over_polyline function, this function calls to it internally. Values provided in param x and y refer to columns of the DataFrame returned by it.

Parameters:
  • x (str) – Value to be used on x-axis of the plot

  • y (str | Property | list | ndarray) – Values to be used on y-axis of the plot

  • mesh (UnstructuredGrid) – Mesh to be sampled

  • profile_points (ndarray) – Points defining the profile (and its segments)

  • ax (axes | None) – User-created array of Matplotlib axis object

  • resolution (int | None) – Resolution of the sampled profile. Total number of points within all profile segments.

  • fontsize (int) – Font size to be used for all captions and labels in the plot

  • twinx (bool | None) – Enable plotting second property on twin-x axis (only works if exactly two properties are provided in props param)

  • resolution – Resolution of the sampled profile. Total number of points within all profile segments.

Returns:

Matplotlib Axes object

Return type:

axes

ogstools.meshplotlib.color_twin_axes(axes, colors)[source]#
Parameters:
  • axes (list)

  • colors (list)

Return type:

None

Submodules#