Mesh Visualization#
Mesh data plotting using matplotlib triangulation (tripcolor, tricontourf) and wireframe rendering via LineCollection.
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 matplotlib triangulation.
For face-centered data: uses tripcolor (each triangle colored by value). For node-centered data: uses tricontourf (interpolated contours). The mesh.triangulation property handles mixed meshes by decomposing each polygon into triangles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh2d
|
Mesh2d topology. |
required |
data
|
ndarray
|
1D data array matching the mesh location count. |
required |
location
|
str
|
"face" or "node". |
'face'
|
ax
|
Any
|
matplotlib Axes. Created if None. |
None
|
cmap
|
str
|
Colormap name. |
'viridis'
|
vmin
|
float | None
|
Minimum color scale value. |
None
|
vmax
|
float | None
|
Maximum color scale value. |
None
|
edgecolor
|
str
|
Edge color for face rendering. |
'none'
|
colorbar
|
bool
|
Whether to add a colorbar. |
True
|
title
|
str | None
|
Plot title. |
None
|
**kwargs
|
Any
|
Additional keyword arguments passed to tripcolor/tricontourf.
Do not pass |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
matplotlib Axes with the plot. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If location is not "face" or "node". |
Source code in src/pyramids/netcdf/ugrid/plot.py
pyramids.netcdf.ugrid.plot.plot_mesh_outline(mesh, ax=None, color='black', linewidth=0.3, **kwargs)
#
Plot mesh edges as a wireframe.
Uses matplotlib LineCollection for efficient rendering of thousands of edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh2d
|
Mesh2d topology. |
required |
ax
|
Any
|
matplotlib Axes. Created if None. |
None
|
color
|
str
|
Edge color. |
'black'
|
linewidth
|
float
|
Edge line width. |
0.3
|
**kwargs
|
Any
|
Additional keyword arguments passed to LineCollection. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
matplotlib Axes with the wireframe plot. |