NCL-style atmospheric & climate vector, contour, and stippling visualization for Matplotlib & Cartopy, powered by Pure-Rust native kernels
Part of the Skyborn (skyborn-org) ecosystem.
- Pure-Rust
_plot_rsCore: Unified PyO3 native extension (rust/skybornplot-core+rust/skybornplot-py) backed byrayonmultithreading, with zero C, Cython, or Fortran runtime dependencies. - Zero-Copy C-Order Buffers & GIL Release: Borrows contiguous
float64/boolslices directly across the PyO3 boundary and automatically releases the Python GIL (py.detach) for workloads with>= 2,048elements. - Cross-Subplot
ref_length_px&plt.quiverCompatibility: Calibrate vector glyph lengths in absolute display pixels across panels of different widths or aspect ratios, with automaticCurlyVectorKeysynchronization andplt.quiver-style aliases (ax=,c=,linewidths=,facecolors=,edgecolors=,pivot=,vmin/vmax). - Swept & Straight Contour Arrowheads:
O(log N)cumulative arc-lengthPathProfilequeries, local straightness scoring, and label-avoiding placement viaarrow_contourandarrow_contour_clabel. - Broad Platform & Python Support: Python 3.9+ and NumPy, with prebuilt wheels for Linux (
manylinux2014_x86_64), macOS (arm64&x86_64), and Windows (win_amd64).
curly_vector normalizes regular, non-uniform (ncl_preset="profile"), curvilinear, and Cartopy-projected grids into display-space coordinates, applies O(1) spatial-hash thinning (thin_display_candidates), integrates curved glyphs in parallel across rayon threads (trace_ncl_glyphs_batch), and builds batched Matplotlib LineCollection (closed-apex open "->" heads) and PolyCollection ("-|>" filled heads) artists. Display-thinned scatter stippling and arrow_contour / arrow_contour_clabel reuse the same Pure-Rust spatial-hashing and PathProfile kernels.
Measured on Apple Silicon (Apple M5, arm64, 10 CPU, 32 GB RAM) comparing Pure-Rust _plot_rs against legacy C/Python kernels and full Matplotlib Agg rendering (24.80× contour arrows, 5.92× 400-glyph Rust batch vs Python loop, 2.63× candidate thinning, and 1.46× end-to-end curly_vector Agg draw).
pip install skyborn-plotOptional geospatial & xarray support:
pip install "skyborn-plot[geo]"Or install the full Skyborn suite:
pip install skybornimport matplotlib.pyplot as plt
import skybornplot as splt
fig, (ax_wide, ax_narrow) = plt.subplots(
1, 2, figsize=(10, 4), gridspec_kw={"width_ratios": [2, 1]}
)
# Identical physical wind speed renders at the exact same 24 px length in both panels
shared = dict(
density=1.1,
arrowstyle="->",
ref_magnitude=10.0,
ref_length_px=24.0,
cmap="viridis",
)
cv_wide = splt.curly_vector(ax_wide, lon_g, lat_g, u_g, v_g, c=speed_g, **shared)
splt.curly_vector_key(ax_wide, cv_wide, U=10.0, label="10 m s⁻¹")
cv_narrow = splt.curly_vector(ax_narrow, lon_r, lat_r, u_r, v_r, c=speed_r, **shared)
splt.curly_vector_key(ax_narrow, cv_narrow, U=10.0, label="10 m s⁻¹")arrow_contour&arrow_contour_clabel: Streamline-aligned directional contour arrows with swept heads and automatic label avoidance.shadow_contourf: Shaded and hatched significance or terrain overlays.scatter: Display-space-thinned stippling that adapts to map projections and panel aspect ratios.gradient_fill_between/GradientFillBetween,createFigure,add_equal_axes,add_centered_axes.
Note: skyborn.plot in the skyborn package seamlessly re-exports skybornplot.
BSD 3-Clause License. See LICENSE.