Skip to content

Draw the SVG plots with rizzma - #1

Open
meawoppl wants to merge 2 commits into
gaker:mainfrom
meawoppl:meawoppl/rizzma
Open

meawoppl wants to merge 2 commits into
gaker:mainfrom
meawoppl:meawoppl/rizzma

Conversation

@meawoppl

Copy link
Copy Markdown

Heyo, I am doing some work to get our sweet (astronomy centric) plotting tools out in the wild. This seemed like a nice entry point, and I thought I might probe your interest in future contributions here...

This ports celestial-pointing/src/plot/svg.rs from plotters to rizzma, a pure-Rust plotting library modelled on matplotlib. The public functions (scatter_svg, histogram_svg, vector_map_svg) keep their signatures, so no callers change, and the textplots terminal renderer is untouched.

What each command draws now:

  • GSCAT / GHA / GDEC / GHYST: the same residual scatter plots, with the zero crosshairs drawn as axhline/axvline instead of path segments.
  • GDIST: hist_with(…, 20 bins) replaces the hand-written binning, which is deleted. Bin counts are identical to before, and the grid sits behind the bars.
  • GMAP: residuals are real arrows with heads (quiver_with, in data units) instead of bare line segments. The [scale] argument still works: an arrow runs from each position to position + scale × residual.

Checked with pointing-data/gem-28.dat (454 observations, fit with IH ID CH NP MA ME): every plot has the expected number of points, bars and arrows, and all 600 crate tests pass. Clippy is clean with -D warnings.

Trade-offs, to be upfront:

  • The dependency tree grows, because rizzma brings a rasteriser and font parser even when only SVG is written. plotters' SVG backend is lighter.
  • The SVGs are a little larger than plotters' (GSCAT: 85 KB vs 61 KB), mainly because text is drawn as outlines. Setting rizzma's svg_fonttype to native text cuts GSCAT to about 33 KB, half of plotters', if you'd prefer that; it's a one-line change.

Happy to adjust styling, or to hold this if you'd rather keep the lighter SVG backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant