STEM Vector Math Plotter & 24-Asset SVG Diagram Pack
How to Generate Clean, Themeable Math SVGs for Technical Docs Without Matplotlib Bloat
Writing technical documentation, ML engineering blogs, or STEM courseware often hits the same snag: you need crisp, dark-mode-friendly mathematical plots and geometric diagrams, and your options are either screenshotting a desktop window or installing a 300 MB Python plotting stack just to render sin(x) or a normal distribution curve.
Why this problem wastes time
Exporting raster PNGs or default scientific charts creates three recurring bottlenecks for developers and technical writers:
- Theme mismatch and blurry scaling: Static PNGs look jagged on high-DPI displays and break in dark-mode documentation sites or blueprint slide decks.
- Uneditable monolithic exports: Standard chart generators dump thousands of ungrouped paths, making it painful to toggle a grid, highlight an asymptote, or move a tangent callout inside Figma or Illustrator.
-
Dependency overhead and broken asymptotes: Pulling
matplotlibandnumpyinto a docs CI pipeline slows builds, while naive curve samplers connect vertical asymptotes (1/x,tan(x),1/(x^2-1)) with ugly diagonal spikes across the canvas.
Step-by-step workflow
You can generate lightweight, responsive, Figma-layered SVGs directly from mathematical expressions using a pure-math recursive-descent parser and SVG <clipPath> geometry guards:
-
Parse equations safely without
eval: Tokenize and parse arithmetic (+,-,*,/,^with right-associative precedence tighter than unary-so-x^2 == -(x^2)), implicit multiplication (2x,2sin(x),(x+1)(x-1)), constants (pi,e,tau), and functions (sin,cos,tan,exp,ln,log10,sqrt,abs,floor,ceil). -
Handle domain gaps and discontinuities cleanly: Skip
NaNor out-of-domain points (such as negative inputs tosqrt(x)orln(x)) and start a freshMsubpath when the domain resumes. Split subpaths automatically wheneverabs(y - prev_y)jumps across a vertical pole like1/(x^2 - 1). -
Structure output into named Figma
<g>layers: Separatebg-layer,grid-layer,axes-layer,shaded-layer,curve-layer(wrapped in<clipPath>), andannotations-layerinside a responsiveviewBox="0 0 800 520"SVG. -
Render from the command line with zero external dependencies: run
python generate_math_svg.py plot --mode explicit --expr "1/(x^2 - 1)" --xmin -4 --xmax 4 --ymin -4 --ymax 4 --theme dark --accent "#38bdf8" --auto-asymptotes -o rational-plot.svgto generate a clean dark-theme SVG with automatic discontinuity splitting and dashed asymptote lines.
Automating it in seconds
If you want to preview equations interactively in your browser before automating full asset sets, try the live STEM Vector Math Plotter in index.html:
- Switch between Explicit (
y = f(x)), Parametric ((x(t), y(t))), and Polar (r(theta)) modes. - Customize
xmin/xmax,light/dark/blueprintthemes, accent hex color, stroke width, grid visibility, and optional tangent line overlays (Tangent @ x₀). - Inspect 6 free preview samples (4 annotated STEM diagrams and 2 seamless patterns), copy clean SVG markup with one click, or download a preview
.svg.
When you are ready to skip drawing diagrams from scratch, the $7.00 Pro 24-Asset Pack on Polar.sh includes:
-
16 multi-layer annotated STEM SVG diagrams (
diagrams/*.svg) covering Unit Circle projections, Normal Distribution±1σ/±2σ/±3σbands, Midpoint Riemann Sums, Taylor Series (sin(x)), Damped Harmonic Oscillator, Fourier Square Wave, ML Activations (Sigmoid/Tanh/ReLU/Softplus), Gradient Descent Contours, Conic Sections, Rational Asymptotes, Lissajous 3:4, Polar Rose & Cardioid, 2D Vector Field Flow, PID Step Response, Cubic Bézier Control Polygon, and Logarithmic Golden Spiral. -
8 seamless tileable
<pattern>SVGs (patterns/*.svg) for Blueprint Grids, Isometric Dots, Polar Radar, Log Graph Paper, Hex Mesh, Trig Waves, Crosshairs, and Chalkboard Dots. -
Offline batch CLI (
generate_math_svg.py+presets.json) so you can regenerate all 24 assets inlight,dark, orblueprintthemes in one command:python generate_math_svg.py batch --presets presets.json --theme blueprint --out-dir ./blueprint-pack.
Try It & Download
- Live Interactive Demo / Tool: https://nuan2779.github.io/auto-tools/products/show-hn-zegrapher-v4-modern-open-source-math-plo-316/
- Full Canonical Guide: https://nuan2779.github.io/auto-tools/blog/show-hn-zegrapher-v4-modern-open-source-math-plo-316/
- Get Bundle on Polar (Card / Apple Pay): https://buy.polar.sh/polar_cl_A4dbN9N7CB7wTaoEIxiXl5HMFnS0cgzlGDazO4d5lrB
Top comments (0)