Plotting Libraries
In this section, you’ll learn:
What general purpose visualization packages are available in the Scientific Python Ecosystem
How functionality of these packages can be useful for unstructured grids visualization
Prerequisites
Concepts |
Importance |
Notes |
---|---|---|
Python |
Necessary |
This notebook does not contain any Python code, but understanding those libraries comprehensively would require Python programming |
Time to learn: 10 minutes
In this section, we will introduce two visualization libraries/technologies and their features and functionality that can be useful for unstructured grids visualization before diving deep into plotting unstructured grids with UXarray in the next chapter.
HoloViz
HoloViz is a stack of tools (such as Holoviews, Datashader, Geoviews, SpatialPandas, hvPlot etc.) that provide high-level functionality to visualize even the very large datasets efficiently in Python. HoloViz packages are well-suited for unstructured grid visualization because:
They provide rendering functionality for both vector geometries and rasterization, which will be detailed in the next section. Such functionality is much needed for unstructured grid topology and data visualization purposes.
Unlike Matplotlib, they support using the connectivity information that comes from the unstructured grids
They are designed to be scalable for even the largest datasets that’d be generated as result of kilometer-scale analyses
Let us look at the particular HoloViz packages that can be useful for scalable visualization of unstructured grids.
HoloViews
Holoviews houses several elements (e.g. Path()
, Points()
) that enables visualization of grid geometries such as nodes and edges. Similarly, other elements of this package (e.g. Polygons()
) can be used for various polygon vector visulization purposes.
Datashader
Datashader is the graphics pipeline system of the HoloViz tool stack for creating meaningful representations of large datasets quickly and flexibly. Datashader’s rasterization methods, transfer functions, and other shading operators can be utilized for rasterized polygon plotting.
GeoViews
GeoViews provides features and functionality to visualize geographical, meteorological, and oceanographic datasets and features.
Spatialpandas
Spatialpandas is a package that provides Pandas extension arrays for spatial/geometric operations. This package has an element called GeoDataFrame
, which can be used directly by packages from the HoloViz stack such as hvPlot, Datashader, Holoviews, and Geoviews. Conversions from unstructured grids to GeoDataFrame
can allow to perform visualizations directly in HoloViz packages.
Matplotlib
Matplotlib is the workhorse of Python visualization needs, for both general and geoscientific purposes. However, when it comes to visualizing unstructured grids, Matplotlib’s:
Functionality is limited such that there is no way to use the connectivity information that comes with the unstructured grid
Scalability especially for kilometer-scale (e.g. individual storm-resolving) resolutions is limited.
Matplotlib can still serve as a visualization backend for unstriuctured grid visualization, especially for the end-user who is familiar with Matplotlib and would like to create publication-quality outputs.
Moreover, just like conversion to Spatialpandas.GeoDataFrame
, conversions to Matplotlib data structures such as Collections
can be utilized for unstructrued grid plotting directly with the Matplotlib interface.
Collections
Detailed information about Matplotlib’s Collections API can be found here. Conversions to LineCollection
and PolyCollection
can help visualize Grid Geometries and data variables, respectively.
Cartopy
Cartopy is originally a Python library for cartographic visualizations with Matplotlib; however, they provide a number of features such as crs
, i.e. Coordinate Reference Systems (a.k.a. projections), that are significant for cartographic visualizations.
What is next?
The next section will provide an overview of the rendering techniques that can be used for visualizing unstructrued grids.