Help us shape the future of Go! Take the 2026 Go Developer Survey

OneFit-Engine-plot

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: Artistic-2.0

README

OneFit-Engine-plot

plot-go will render the Grace (xmgrace) project files OneFit writes - the .agr/.agr-par plots of every fit - straight to PDF, SVG and PNG, without Grace, Ghostscript or epstopdf. It is a batch renderer for the part of the Grace format OneFit uses, not a clone of xmgrace; interactive plots are the OneFit GUI's job.

Status: steps 1 to 5 are done. plot-go FILE.agr writes a PDF (or EPS, SVG) without Grace; the renderer matches gracebat primitive by primitive, and the output matches gracebat's page pixel for pixel, allowing for text placed up to 0.7 pt apart (see docs/grace-behaviour.md). plot-go also takes gracebat's own command line - the one OneFit's C core gives Grace, recorded from real fits in testdata/gracebat-call* - and writes the same EPS and a saved project that redraws it. With plot-go in Grace's place, all nine OneFit-Engine test suites produce the same 110 plots as with Grace. Next: making OneFit use it (step 6).

go install ./cmd/plot-go
plot-go fit-curves-1.agr                  # -> fit-curves-1.pdf
plot-go -o plot.svg fit-curves-1.agr      # format from the extension
plot-go -format eps fit-curves-1.agr      # what OneFit's C core asks for

# gracebat's command line, as OneFit's C core calls Grace:
plot-go -settype xydy gnu0.da_ -nxy fit-curves-1 -param fit1.agr-par \
  -hdevice EPS -hardcopy -printfile fit-curves-1.eps -saveall fit-curves-1.agr

Plan

  1. Inventory: list every directive and text escape OneFit's files use (cmd/agr-inventory, results in docs/features.md and docs/inventory.md).
  2. Parser and model for that part of the format.
  3. Renderer: page/viewport/world coordinates, normal and log axes, ticks and tick labels, xy and xydy sets, symbols, line styles, error bars, legend, strings, Grace text escapes.
  4. Reference tests: render a curated set of real files with plot-go and with gracebat, rasterise both, compare within a tolerance, in CI.
  5. A command line compatible with the gracebat call OneFit's C core makes (-nxy, -settype xydy, -param, -printfile, -device, -saveall), writing PDF directly.
  6. The C core uses plot-go when installed and falls back to gracebat; onefite doctor reports which.
  7. A live, editable preview in the OneFit GUI: the GUI shows plot-go's SVG - the same drawing as the PDF - and edits (ranges, labels, styles, texts) go into the .agr and re-render. Both are Artistic 2.0, so the GUI can use plot-go as a library.

Install

Prebuilt binaries for Linux (amd64, arm64), macOS (Intel, Apple Silicon) and Windows are attached to each release (plot-go_OS_ARCH, with SHA256SUMS; releases/latest/download/plot-go_linux_amd64 is always the newest); put one on the PATH as plot-go. Or, with Go: go install github.com/fitteia/OneFit-Engine-plot/cmd/plot-go@latest.

OneFit's C core (OneFit-Engine-C) uses plot-go for its plots when it finds it on the PATH, and Grace otherwise; OFE_PLOTTER=grace forces Grace.

Clean-room rule

plot-go is distributed under the Artistic License 2.0 (see LICENSE and NOTICE). Grace is GPL, so plot-go is written from the format itself and Grace's documentation (the User's Guide), never from Grace's source code. gracebat is used only as a black box: its output is the reference the tests compare against.

Test data

  • testdata/corpus/: nine real OneFit plots chosen to cover the format's variety - normal and log axes, decimal and power tick labels, 3 to 7 sets, curve labels, every text escape, small symbols, and one malformed tick label format. They come from the OneFit-Engine test suites and the p96-10 sample that is already public in OneFit-Engine-assistant.
  • testdata/ref/: gracebat's rendering of each, made by scripts/make-references.sh (gracebat -> EPS -> Ghostscript, the whole page at 144 dpi). Regenerating gives byte-identical files.

Development

go vet ./...
go test ./...
go run ./cmd/agr-inventory -o docs/inventory.md DIR...
PLOT_GO_CORPUS=DIR:DIR go test ./agr/   # also parse a whole local corpus
scripts/make-references.sh               # needs gracebat and gs

Directories

Path Synopsis
Package agr reads Grace project files (.agr, .agr-par) - the part of the format OneFit writes (see docs/features.md) - into a Project.
Package agr reads Grace project files (.agr, .agr-par) - the part of the format OneFit writes (see docs/features.md) - into a Project.
Package backend writes a draw.Drawing as a file: EPS (what OneFit's C core asks gracebat for), PDF (cropped as epstopdf crops gracebat's EPS), and SVG.
Package backend writes a draw.Drawing as a file: EPS (what OneFit's C core asks gracebat for), PDF (cropped as epstopdf crops gracebat's EPS), and SVG.
cmd
agr-inventory command
agr-inventory lists which parts of the Grace project format (.agr and .agr-par files) a set of files actually uses: every directive, reduced to its shape (graph/set numbers become #, numbers N, strings STR), with how many lines and files use it, and every text escape found inside strings.
agr-inventory lists which parts of the Grace project format (.agr and .agr-par files) a set of files actually uses: every directive, reduced to its shape (graph/set numbers become #, numbers N, strings STR), with how many lines and files use it, and every text escape found inside strings.
grace-probe command
grace-probe runs gracebat on a Grace project and prints what it draws, one primitive per line, in viewport units - the black-box measurements plot-go is built from (see AGENTS.md: gracebat's output, never Grace's source).
grace-probe runs gracebat on a Grace project and prints what it draws, one primitive per line, in viewport units - the black-box measurements plot-go is built from (see AGENTS.md: gracebat's output, never Grace's source).
plot-go command
plot-go renders a Grace project file (.agr) the way gracebat does, without Grace: to PDF, EPS or SVG.
plot-go renders a Grace project file (.agr) the way gracebat does, without Grace: to PDF, EPS or SVG.
Package draw is the drawing plot-go makes of a page: paths and texts in viewport units (the page's shorter side is 1, origin at the bottom left), in the order they are drawn.
Package draw is the drawing plot-go makes of a page: paths and texts in viewport units (the page's shorter side is 1, origin at the bottom left), in the order they are drawn.
internal
afm
Package afm gives plot-go the metrics of the 14 standard PDF fonts: each character's advance width and ink box, from Adobe's Core 14 AFM files (adobe-core14/, distributed with Adobe's MustRead.html as its terms require; see NOTICE).
Package afm gives plot-go the metrics of the 14 standard PDF fonts: each character's advance width and ink box, from Adobe's Core 14 AFM files (adobe-core14/, distributed with Adobe's MustRead.html as its terms require; see NOTICE).
drawcmp
Package drawcmp compares two drawings - plot-go's and gracebat's (read from its EPS by internal/eps) - primitive by primitive.
Package drawcmp compares two drawings - plot-go's and gracebat's (read from its EPS by internal/eps) - primitive by primitive.
eps
Package eps reads the EPS that gracebat writes into a list of drawing primitives - paths, arcs and texts with their exact coordinates - so plot-go's drawing can be compared with gracebat's number by number.
Package eps reads the EPS that gracebat writes into a list of drawing primitives - paths, arcs and texts with their exact coordinates - so plot-go's drawing can be compared with gracebat's number by number.
Package render draws a Grace project (agr.Project) the way gracebat does, into a draw.Drawing.
Package render draws a Grace project (agr.Project) the way gracebat does, into a draw.Drawing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL