Mesh Visualization#
Mesh data plotting using matplotlib triangulation (tripcolor, tricontourf) and wireframe rendering via LineCollection.
UgridDataset.plot is a thin facade over the shared module-level helper
pyramids.dataset._plot_helpers.mesh_render — the same "resolve the data, hand it to one
helper (which also applies the optional web-tile basemap)" contract used by the raster path
(Dataset.plot / NetCDF.plot). The functions below are the low-level entry points it builds
on; the cleopatra optional dependency is checked via pyramids.base._utils.require_cleopatra.
pyramids.netcdf.ugrid.plot.plot_mesh_data(mesh, data, location='face', ax=None, cmap='viridis', vmin=None, vmax=None, edgecolor='none', colorbar=True, title=None, **kwargs)
#
Plot mesh data using cleopatra MeshGlyph.
Renders unstructured mesh data on a matplotlib figure. For
face-centered data, uses tripcolor (each triangle colored
by the value of its parent face). For node-centered data, uses
tricontourf (smooth interpolated contours). All rendering
is delegated to cleopatra.mesh_glyph.MeshGlyph.plot.
The returned MeshGlyph instance gives access to the
underlying Figure/Axes and all cleopatra capabilities
(color scales, animations, etc.).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh2d
|
Mesh2d topology object containing node coordinates and face-node connectivity. |
required |
data
|
Any
|
1D data array. Length must match |
required |
location
|
str
|
Mesh element location for the data. Either
|
'face'
|
ax
|
Any
|
Matplotlib Axes to plot on. If None, a new figure and axes are created. Defaults to None. |
None
|
cmap
|
str
|
Matplotlib colormap name. Only forwarded if different
from the default |
'viridis'
|
vmin
|
float | None
|
Minimum value for the color scale. If None, computed from the data. Defaults to None. |
None
|
vmax
|
float | None
|
Maximum value for the color scale. If None, computed from the data. Defaults to None. |
None
|
edgecolor
|
str
|
Edge color for face rendering. Use |
'none'
|
colorbar
|
bool
|
Whether to add a colorbar to the plot. Defaults to True. |
True
|
title
|
str | None
|
Plot title string. Defaults to None (no title). |
None
|
**kwargs
|
Any
|
Additional keyword arguments forwarded to
|
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
cleopatra.mesh_glyph.MeshGlyph: The MeshGlyph instance with
the plot rendered. Access |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
OptionalPackageDoesNotExist
|
If cleopatra is not installed. |
See Also
plot_mesh_outline: Plot mesh edges as a wireframe. UgridDataset.plot: Dataset-level convenience method that calls this function.
Source code in src/pyramids/netcdf/ugrid/plot.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
pyramids.netcdf.ugrid.plot.plot_mesh_outline(mesh, ax=None, color='black', linewidth=0.3, **kwargs)
#
Plot mesh edges as a wireframe using cleopatra MeshGlyph.
Renders the mesh structure as a wireframe showing all edges.
If the mesh has pre-built edge_node_connectivity, edges
are drawn directly. Otherwise, unique edges are derived from
the face-node connectivity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh2d
|
Mesh2d topology object containing node coordinates and connectivity arrays. |
required |
ax
|
Any
|
Matplotlib Axes to plot on. If None, a new figure and axes are created. Defaults to None. |
None
|
color
|
str
|
Edge color as a matplotlib color string. Defaults
to |
'black'
|
linewidth
|
float
|
Edge line width in points. Defaults to |
0.3
|
**kwargs
|
Any
|
Additional keyword arguments passed to
|
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
cleopatra.mesh_glyph.MeshGlyph: The MeshGlyph instance with
the wireframe rendered. Access |
See Also
plot_mesh_data: Plot data values on the mesh. UgridDataset.plot_outline: Dataset-level convenience method.