From 87d0496ecc31a5e6e7e49ade645a6312cc63acb5 Mon Sep 17 00:00:00 2001 From: tannevaled Date: Mon, 26 Oct 2026 18:24:19 +0100 Subject: [PATCH] =?UTF-8?q?docs:=20go-plot=20v0.3.0=20=E2=80=94=20text=20f?= =?UTF-8?q?rom=20data=20without=20TeX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- README.md | 6 +++--- content/en/_index.md | 12 +++++++----- content/en/getting-started.md | 2 +- content/en/plot-types.md | 2 +- content/en/tex.md | 19 +++++++++++++++++++ figures/go.mod | 2 +- figures/go.sum | 4 ++-- hugo.yaml | 4 ++-- 8 files changed, 36 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 11ec4fd..92fe005 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ while no release is tagged: `https://go-plot.github.io/docs/` redirects to `latest/`. Each push to `main` replaces the directory of the version it describes, and nothing else. The -pages describe **v0.2.0**, published under `0.2/`. +pages describe **v0.3.0**, published under `0.3/`. To document a new release, set `params.plot.version` to its tag, require the same version in `figures/go.mod`, redraw the figures, and update the pages. @@ -68,10 +68,10 @@ cd figures && go run . git clone --recurse-submodules https://github.com/go-plot/docs.git cd docs mkdir -p data && sh themes/hextra/scripts/page-history.sh > data/pagehistory.json -hugo server --baseURL http://localhost:1313/docs/0.2/ +hugo server --baseURL http://localhost:1313/docs/0.3/ ``` -then open . Hugo 0.146 or later; no Python, +then open . Hugo 0.146 or later; no Python, no Node. Go 1.27.2 or later only to redraw the figures. ## Publication diff --git a/content/en/_index.md b/content/en/_index.md index f3cb046..a61b102 100644 --- a/content/en/_index.md +++ b/content/en/_index.md @@ -20,16 +20,18 @@ set by a real TeX math typesetter, [go-tex/math](https://github.com/go-tex/math) A sine curve drawn as a line and as markers, with a TeX label and a legend These pages describe [go-plot/plot](https://github.com/go-plot/plot) -**v0.2.0**. Every figure in them was drawn by that version, from the code shown -beside it. New in v0.2.0: +**v0.3.0**. Every figure in them was drawn by that version, from the code shown +beside it. -- [pie and donut charts]({{< relref "plot-types#pie-and-donut" >}}). -- An SVG that can be inlined under a strict Content-Security-Policy. +- New in v0.3.0: [text from data, without TeX]({{< relref "tex#text-from-data-no-tex" >}}). +- New in v0.2.0: + - [pie and donut charts]({{< relref "plot-types#pie-and-donut" >}}); + - an SVG that can be inlined under a strict Content-Security-Policy. ## Install ```sh -go get github.com/go-plot/plot@v0.2.0 +go get github.com/go-plot/plot@v0.3.0 ``` The module needs Go 1.27.2 or later. It is pure Go (`CGO_ENABLED=0`) and builds diff --git a/content/en/getting-started.md b/content/en/getting-started.md index 38b611c..b6fe024 100644 --- a/content/en/getting-started.md +++ b/content/en/getting-started.md @@ -8,7 +8,7 @@ tags: [start] ## Install ```sh -go get github.com/go-plot/plot@v0.2.0 +go get github.com/go-plot/plot@v0.3.0 ``` Go 1.27.2 or later. Nothing else: no Python, no C library, no font to install. diff --git a/content/en/plot-types.md b/content/en/plot-types.md index 2d5f7fd..fcbbca9 100644 --- a/content/en/plot-types.md +++ b/content/en/plot-types.md @@ -5,7 +5,7 @@ description: "Every plot type of v0, each with the code that drew it." tags: [api, gallery] --- -Each figure on this page was drawn by go-plot v0.2.0 from the code below it. +Each figure on this page was drawn by go-plot v0.3.0 from the code below it. The code is not a copy: the page reads it from [`figures/`](https://github.com/go-plot/docs/tree/main/figures) in this site's repository, where `go run .` draws every image, and the CI draws them diff --git a/content/en/tex.md b/content/en/tex.md index 33c138f..efd6da6 100644 --- a/content/en/tex.md +++ b/content/en/tex.md @@ -46,6 +46,25 @@ OS/2 table, alignment, rotation, anchoring), and like Agg the pen is put on a whole pixel. How the pixels of text differ from matplotlib's is on [Differences]({{< relref "differences#text" >}}). +## Text from data: no TeX + +A string is read as matplotlib reads it: TeX between an even number of +unescaped dollar signs. Names that come from data ("100$", a team called +`$x$`) should not be. go-plot follows matplotlib's `parse_math`: + +| go-plot | matplotlib | +| --- | --- | +| `plot.NewFigure(plot.ParseMath(false))`, `fig.SetParseMath(false)` | `rcParams["text.parse_math"] = False` | +| `plot.PlainText()` on one call | `parse_math=False` on that text | +| `plot.MathText()` on one call | `parse_math=True` on that text | + +The calls that take it are `SetTitle`, `SetXLabel` and `SetYLabel`. So do +`SetXTickLabels` and `SetYTickLabels` (category names under bars), `Legend` +(every entry), `Text`, `Annotate` and `Pie`. A plain string is drawn +character for character as glyph outlines. It never reaches the TeX +typesetter, and `