Skip to content

Latest commit

 

History

History
62 lines (49 loc) · 3.24 KB

NUGET.md

File metadata and controls

62 lines (49 loc) · 3.24 KB

Marey

Figures, fields, simulations and animations for F#, where the compiler checks the units and the axes label themselves. Marey is the library in one reference: units, the plotting grammar, fields, simulations, animation, live figures, and SVG, TikZ and HTML output.

#r "nuget: Marey"

open Marey
open Marey.UnitsOfMeasure

let t = Array.init 400 (fun i -> float i * 0.01<s>)
let x = t |> Array.map (fun t -> 0.012<m> * exp (-t / 1.5<s>) * cos (2.0 * System.Math.PI * 1.2<Hz> * t))
let stiffness = 40.0<N/m>

let spring =
    Chart.lineIn U.second U.metre t x
    |> Chart.above (Chart.lineIn U.second U.joule t (x |> Array.map (fun x -> 0.5 * stiffness * x * x)))
    |> Chart.shareX
    |> Chart.withTitle "A damped spring"

spring |> Chart.toSvg SvgBackend.render "spring.svg" (Chart.size 720.0 480.0)

Nothing set an axis. The displacement was computed in metres and reads x [mm]; the energy, ½ k x² with k in N/m, is a float<J> because the compiler worked it out, and reads in mJ. Plotting seconds against a metres axis does not compile. Under Theme.tikz the same figure is a tikzpicture, typeset by the LaTeX document with siunitx units.

In a Verso notebook, a first cell of #!extension Marey.Verso makes a figure display as a figure and a figure with controls live.

The packages

Marey depends on every package below that needs no native library or external program. The others are separate references.

Package
Marey.Core, Marey.Units Dimensions, unit witnesses, scales, colour, and the scene every backend draws.
Marey.Plot Chart, the plot block, layout, themes, the storyboard.
Marey.Anim, Marey.Fields, Marey.Sim Animation, fields, simulation.
Marey.Uncertainty Measured values with their standard uncertainty, as the GUM evaluates it: budgets, error bars, weighted fits, a Monte Carlo check.
Marey.Interact, Marey.Html Live figures, and HTML for a notebook cell.
Marey.Backend.Svg, Marey.Backend.Tikz SVG, and tikzpicture source for LaTeX.
Marey.Backend.Skia PNG and vector PDF with text shaped by HarfBuzz. Not in Marey: it brings SkiaSharp's natives.
Marey.Backend.Gpu The GPU, offscreen or in a window. Not in Marey.
Marey.Backend.Web A canvas in a browser, for a Fable app. Not in Marey.
Marey.Tools.Tex, Marey.Tools.Video Typeset text through latex and dvisvgm, video through ffmpeg. Not in Marey.
Marey.Verso The Verso notebook extension, loaded by #!extension Marey.Verso.
Marey.Analyzers, Marey.Witnesses Fixes for a call missing the right unit witness: F# analyzers for Ionide and the CLI, and the same fixes over the compiler service. Not in Marey.

Marey is at 1.1.0, and the compatibility page says what a version number promises from here on. MIT licensed.