Visualization
Visualization utilities for the MONET Stats package. These functions follow the Aero Protocol's "Two-Track Rule": Track A for static publication-quality plots and Track B for interactive exploration.
Visualization utilities for the MONET Stats package (Aero Protocol Compliant).
This module implements the "Two-Track Rule" for scientific visualization: - Track A (Publication): Static quality using Matplotlib and Cartopy. - Track B (Exploration): Interactive exploration using HvPlot and GeoViews.
plot_spatial(da, method='matplotlib', lat_dim='lat', lon_dim='lon', title=None, cmap='viridis', **kwargs)
Plot spatial data following the Aero Protocol's Two-Track Rule.
Parameters
da : xarray.DataArray
The spatial data to plot. Must have latitude and longitude coordinates.
method : str, optional
The plotting track to use:
- 'matplotlib' (Track A): Static publication quality.
- 'hvplot' (Track B): Interactive exploration.
Default is 'matplotlib'.
lat_dim : str, optional
Name of the latitude dimension/coordinate. Default is 'lat'.
lon_dim : str, optional
Name of the longitude dimension/coordinate. Default is 'lon'.
title : str, optional
Title for the plot.
cmap : str, optional
Colormap to use. Default is 'viridis'.
**kwargs : Any
Additional keyword arguments passed to the underlying plotting function.
For 'matplotlib', these are passed to da.plot().
For 'hvplot', these are passed to da.hvplot.quadmesh().
Returns
Any The plot object (matplotlib.axes.Axes or holoviews.element.Element).
Raises
ValueError If an unknown method is specified. ImportError If the required libraries for the chosen track are missing.
Examples
import xarray as xr import numpy as np da = xr.DataArray(np.random.rand(10, 10), ... coords={'lat': np.arange(10), 'lon': np.arange(10)}, ... dims=('lat', 'lon'))
Track A (Static)
ax = plot_spatial(da, method='matplotlib')
Track B (Interactive)
plot = plot_spatial(da, method='hvplot')
Source code in src/monet_stats/visualize.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 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 | |