Visualizing Grid Topology#

Authors: Philip Chmielowiec


This usage example showcases how to use UXarray’s plotting API to visualize the topology of an unstructured grid (i.e., the elements that make up a grid). The majority of this notebook uses the Primal Mesh of an MPAS Ocean Grid, with the final example using an MPAS Atmosphere Grid.


UXarray’s Plotting API is build around the Holoviews package. For details about customization and accepted parameters, pleases refer to their documentation.

import uxarray as ux
base_path = "../../test/meshfiles/mpas/QU/"
grid_path = base_path + ""
uxds = ux.open_dataset(grid_path, grid_path)
grid = uxds.uxgrid

Using the Grid.plot() Accessor#

Each Grid object is initialized with a plotting accessor, which enables plotting routines to be called directly on the object. By default, calling .plot() on a Grid instance plots all the edges of a grid.

grid.plot(title="Default Grid Plot Method", height=350, width=700)

Since all of our plotting methods are built around the Holoviews package, you can select between Matplotlib and Bokeh backends if desired (Bokeh is the default and is suggested).

    title="Default Grid Plot Method with Matplotlib Backend",

Since each UxDataArray and UxDataset is paired with a Grid objected through the .uxgrid attribute, the same function calls can be executed

    title="Default Plot Method through uxgrid Accessor", height=350, width=700