Skip to content

Gnuplot diagram

Produced by GNUPLOT 5.4 patchlevel 0 0 0.2 0.4 0.6 0.8 1-4-2 0 2 4Gaussian DistributionΒ΅= 0.5 Οƒ=0.5Β΅= 2.0 Οƒ=1.0Β΅=-1.0 Οƒ=2.0

Example taken here

About

Gnuplot is a graphing utility. The source code is copyrighted but freely distributed (i.e., you don’t have to pay for it). It was originally created to allow scientists and students to visualize mathematical functions and data interactively. It is also used as a plotting engine by third-party applications like Octave. Gnuplot has been supported and under active development since 1986.

Installation

  1. Install dependencies

    Terminal window
    pnpm add @beoe/rehype-gnuplot
  2. Configure Astro. See note about Rehype plugins for code.

    astro.config.mjs
    import { rehypeGnuplot } from "@beoe/rehype-gnuplot";
    export default defineConfig({
    markdown: {
    rehypePlugins: [[rehypeGnuplot, { class: "not-content" }]],
    },
    });
  3. Optional install dependency for cache

    Terminal window
    pnpm add @beoe/cache
  4. Optional configure cache

    astro.config.mjs
    import { getCache } from "@beoe/cache";
    const cache = await getCache();
    export default defineConfig({
    markdown: {
    rehypePlugins: [[rehypeGnuplot, { class: "not-content", cache }]],
    },
    });
  5. Optional add pan and zoom for diagrams

Example

```gnuplot
plot [-10:10] sin(x)
```
Produced by GNUPLOT 5.4 patchlevel 0-1-0.8-0.6-0.4-0.2 0 0.2 0.4 0.6 0.8 1-10-5 0 5 10sin(x)

Bonus: XKCD-style

Produced by GNUPLOT 5.4 patchlevel 0Wasted timeDamped SinDamped CosCheck this out! XKCD in Gnuplot

Example taken here

Note: in order for example to work as SVG I changed following lines:

set term postscript eps font 'HumorSans' fontfile 'Humor-Sans.pfa' 22
set output 'xkcd.eps'
set terminal svg enhanced font "HumorSans,Patrick Hand,Chalkboard,Comic Sans MS,18"

You may use any font you like and load if, for example: