Data Visualization Examples¶
Examples demonstrating visualization and plotting functions for time series and flux data.
24 examples across 10+ plot types.
Examples by Plot Type¶
Heatmaps¶
plot_heatmap_datetime_basic.py — Datetime heatmaps (vertical/horizontal layouts, value overlay on 6-hourly grids)
plot_heatmap_advanced.py — Year-month heatmaps: aggregation method comparison (mean/max/std), rank mode, multi-variable side-by-side
plot_heatmap_xyz_basic.py — Pre-aggregated 2D heatmaps from GridAggregator (mean and std, flux binned by temperature and VPD)
Scatter Plots¶
plot_scatter_xy_basic.py — 2D scatter plots showing variable relationships
plot_scatter_xy_colored.py — 3D scatter with color coding, binning, and trend visualization
Time Series¶
plot_timeseries.py — Line plots with matplotlib
plot_timeseries_interactive.py — Interactive Bokeh plots with zoom, pan, and export
plot_timeseries_rangetool.py — Interactive Bokeh plot with a RangeTool overview for navigating long series
Diurnal & Cumulative Patterns¶
plot_dielcycle.py — Diurnal cycles grouped by month or season
plot_cumulative_basic.py — Cumulative flux over time with scenario comparison
plot_cumulative_year.py — Yearly cumulative sums with reference bands
plot_waterfall.py — Daily CO2 uptake/release waterfall building a running flux budget
Distributions¶
plot_histogram_basic.py — Histograms with z-score overlay, peak detection, and custom bin edges
plot_histogram_yearly.py — Year-over-year histograms showing temporal patterns
plot_shifted_distribution.py — Compare how a variable’s distribution has shifted between a reference and a comparison period (Hansen et al. ±1σ/±3σ zones)
Density & Binning¶
plot_hexbin_basic.py — 2D hexagonal binning with percentile normalization and sparse-bin filtering
plot_hexbin_advanced.py — Hexbin plots with absolute values and overlays
plot_ridgeline_basic.py — Ridge plots grouped by week
plot_ridgeline_advanced.py — Ridge plots grouped by month with styling options
Circular / Spiral¶
plot_treering_temperature.py — Tree-ring spiral: annual data as concentric rings, color = value, month labels around circumference, optional month lines and year separators, colorbar auto-extension
plot_treering_line_temperature.py — Tree-ring radial line plot: each year as a line trace around a full circle; radial displacement encodes value; single-color and per-year colormap variants with optional fill between baseline and line
plot_windrose_basic.py — Wind rose: a variable aggregated into wind-direction sectors (mean/median/min/max/sum/std/count) drawn as polar bars; baseline handles negative aggregates; the per-sector results table is available on
.resultsand printed as a Rich tableplot_compound_extremes.py —
CompoundExtremesPlot: quadrant scatter of two standardized drivers (z-scores) coloured/marked by compound-extreme category with dashed threshold lines (after Wang et al., Fig. 2); built from a fittedCompoundExtremes, with custom styling, or from pre-classified data
Other Plots¶
plot_other_plots.py — Long-term anomalies and trend visualization
Two-Phase Design¶
All plotting classes separate data preparation from presentation:
Phase 1: __init__() takes data and computation parameters.
Phase 2: plot() handles axes, colors, and rendering. Chrome (title, axis labels,
units, fonts, grid, legend) is passed as a single FormatStyle via format_style.
This lets you reuse the same data across multiple plots with different visual styles:
scatter = dv.plotting.ScatterXY(x=df['A'], y=df['B'], z=df['C'], nbins=10)
scatter.plot(ax=axes[0], format_style=dv.plotting.FormatStyle(title='View 1'), cmap='viridis')
scatter.plot(ax=axes[1], format_style=dv.plotting.FormatStyle(title='View 2'), cmap='plasma')
Build a FormatStyle once and vary single fields with .merged(**overrides) to keep
the same look across plots — see plot_scatter_xy_colored.py.
Available Plot Classes¶
See dv.plotting for the complete API:
HeatmapDateTime— Datetime-aware heatmapsHeatmapXYZ— Pre-aggregated 2D heatmapsHeatmapYearMonth— Year-month aggregationDateTimeSurface— Numeric grid of a series as date × time-of-dayScatterXY— Customizable 2D/3D scatterCumulative— Cumulative sum plotsCumulativeYear— Yearly cumulative analysisWaterfallPlot— Floating bars of sequential contributions to a running totalLongtermAnomaliesYear— Yearly anomalies against a reference periodTimeSeries— Line plotsDielCycle— Diurnal cycle plotsHistogramPlot— Distribution histogramsHexbinPlot— 2D hexagonal binningRidgeLinePlot— Ridge line plotsShiftedDistributionPlot— Compare a variable’s distribution between two periodsTreeRingPlot— Circular spiral: annual rings with color-coded valuesWindRosePlot— A variable aggregated into wind-direction sectors as polar barsCompoundExtremesPlot— Quadrant scatter of two standardized drivers by extreme categoryFormatStyle— Chrome (title, labels, units, fonts, grid, legend) for anyplot()
Running Examples¶
# Single example
uv run python examples/visualization/plot_heatmap_datetime_basic.py
uv run python examples/visualization/plot_scatter_xy_colored.py
# All visualization examples
uv run python examples/run_all_examples.py
All 24 examples follow the two-phase design pattern.