gnuplot gallery · examples/simple.lms
Simple functions
functions with points (gnuplot simple.dem)
Loading the WebAssembly host…
What runs
The page fetches examples/simple.bin, 626 bytes of lmcode bytecode
(sha256 b81403ba8981…), and hands it to the same lmplot.wasm every example uses.
The bytecode calls the host's Plot functions (plot.cmd, plot.data, plot.num,
plot.png …); gnuplot draws into an in-memory file system and the page shows the files the program wrote.
In SVG mode plot.png("x.png", w, h) writes x.svg with gnuplot's svg terminal; PNG mode uses lmplot's
own rasterizer and fonts, the same bytes as the native binary.
The program was compiled ahead of time from the source on the right with lmscript; the lmscript lines around the
_lmcode_ block (data generation, ${...} values, run_lmcode) ran at compile time.
# Simple functions: gnuplot's "simple.dem" first plots, driven from lmscript.
mkdir("images");
mkdir("build");
p = _lmcode_ cli="lmplot" install="github:lmctl-ai/lmplot@v0.3.1";
plot.png("images/simple.png", 800, 600);
plot.cmd("set title 'Simple Plots' font ',16'");
plot.cmd("set key left box");
plot.cmd("set samples 50");
plot.cmd("set style data points");
plot.cmd("plot [-10:10] sin(x), atan(x), cos(atan(x))");
plot.close();
end _lmcode_
r = run_lmcode(p);
assert(r.ok, json_stringify(r));
println("wrote images/simple.png");