ogstools.meshplotlib.core module#
Meshplotlib core utilitites.
- ogstools.meshplotlib.core.get_level_boundaries(levels)[source]#
- Parameters:
levels (ndarray) –
- Return type:
ndarray
- ogstools.meshplotlib.core.get_cmap_norm(levels, mesh_property)[source]#
Construct a discrete colormap and norm for the property field.
- Parameters:
levels (ndarray) –
mesh_property (Property) –
- Return type:
tuple[Colormap, Normalize]
- ogstools.meshplotlib.core.get_ticklabels(ticks)[source]#
Get formatted tick labels and optional offset str.
If all values in ticks are too close together offset notation is used.
- Parameters:
ticks (ndarray) –
- Return type:
tuple[list[str], str | None]
- ogstools.meshplotlib.core.add_colorbars(fig, ax, mesh_property, levels, pad=0.05, labelsize=None)[source]#
Add a colorbar to the matplotlib figure.
- Parameters:
fig (Figure) –
ax (Axes | list[Axes]) –
mesh_property (Property) –
levels (ndarray) –
pad (float) –
labelsize (float | None) –
- Return type:
None
- ogstools.meshplotlib.core.get_projection(mesh)[source]#
Identify which projection is used: XY, XZ or YZ.
- Parameters:
mesh (UnstructuredGrid) – singular mesh
- Return type:
tuple[int, int]
- ogstools.meshplotlib.core.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.core.clear_labels(axes)[source]#
- Parameters:
axes (Axes | ndarray) –
- Return type:
None
- ogstools.meshplotlib.core.label_spatial_axes(axes, x_label='x', y_label='y')[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) –
- Return type:
None
- ogstools.meshplotlib.core.get_combined_levels(meshes, mesh_property)[source]#
Calculate well spaced levels for the encompassing property range in meshes.
- Parameters:
meshes (ndarray) –
mesh_property (Property | str) –
- Return type:
ndarray
- ogstools.meshplotlib.core.get_data_aspect(mesh)[source]#
Calculate the data aspect ratio of a 2D mesh.
- Parameters:
mesh (UnstructuredGrid) –
- Return type:
float
- ogstools.meshplotlib.core.update_font_sizes(fig, fontsize=20)[source]#
Update font sizes of lebels and ticks in all subplots
- Parameters:
fig (Figure) – Matplotlib Figure object to use for plotting
int – New font size for the labels and ticks (optional)
fontsize (int) –
- Return type:
Figure
- ogstools.meshplotlib.core.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.core.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