cd /news/developer-tools/foresight-fortran-easy-svg-interacti… · home › topics › developer-tools › article
[ARTICLE · art-177638] src=fortran-lang.discourse.group ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

Foresight, FORtran Easy Svg Interactive Gnuplot-like Html Tool, v0.20.0 is out

Stefano Zaghi released foresight v0.20.0, a pure Fortran plotting library and command-line tool that interprets a large subset of gnuplot 6.0's language and writes interactive HTML pages, SVG, PDF with embedded fonts, LaTeX pictures and terminal text without Python, gnuplot or any graphics library. The release adds a `--watch` mode that re-renders a figure as a running solver appends to its log while preserving zoom, and the author notes foresight has shipped twenty minor releases in two months, is used so far mostly by its author, and may still change its API before v1.0.

key takeaway

foresight v0.20.0 lets Fortran solvers render gnuplot-script figures to interactive HTML, SVG, PDF and LaTeX with only a Fortran compiler, and `foresight --watch run.gp` re-renders the page as the job's log grows while keeping the viewer's zoom.

read4 min views5 publishedNov 28, 2026

FORtran Easy Svg Interactive Gnuplot-like Html Tool

foresight is a pure Fortran library and a command-line tool. It draws what gnuplot draws, from your solver’s arrays or from a gnuplot script: interactive HTML pages that need nothing but a browser, SVG, PDF with embedded fonts, LaTeX pictures, and text for a terminal. It needs no Python, no gnuplot, and no graphics library: only a Fortran compiler. v0.20.0 is the first release I announce here (written with the help of an AI assistant).

Disclaimer: foresight and fplotlib. fplotlib (fortran-lang) overlaps with foresight in part: both are pure Fortran, both write figures for papers, both set TeX math in labels. They are siblings, not one built on the other, and they differ:

Interface. fplotlib offers matplotlib’s interface from Fortran. foresight’s interface is gnuplot’s: its command language, interpreted in Fortran, and a Fortran API named after the commands (fig%set_logscale('y') is set logscale y). Outputs. fplotlib writes images, PNG, GIF, and EPS among them. foresight writes interactive pages and vector formats (SVG, PDF, LaTeX pictures), and no raster images at all. Choose fplotlib for matplotlib’s style, raster output, or LFortran and flang. Choose foresight when your figures are, or should be, gnuplot scripts; when you watch a running job; or when your LaTeX paper should set its own labels. foresight takes no code from fplotlib, but it borrows fplotlib’s method of checking a layout against a reference typesetter glyph by glyph. The comparison page has the details. foresight is also young: twenty minor releases in two months, used so far mostly by its author, and its API may still change before v1.0.

foresight --watch: a run’s log grows, and the page redraws, keeping your zoom; the readout shows the latest iteration.

1. gnuplot, from Fortran. foresight interprets a large subset of gnuplot 6.0’s language: plot, splot, fit, stats, set table, functions, loops, datablocks, enhanced text and the 2D styles. Each feature is probed on gnuplot before it is written, and a harness compares gnuplot’s own demo pages, drawn by both programs, page by page. Run your scripts with foresight script.gp, or call the same commands from your program. A script can keep running in gnuplot too. A command outside the subset is an error naming its line, never silently skipped.

2. Watch a running job. foresight --watch run.gp re-renders whenever the solver appends to its log:

3. Figures for papers and reports.

pdfcairo syntax, size single for a journal column), with two font families compiled in and embedded.$\frac{t}{\tau}$), laid out as LaTeX lays it out. cairolatex, so your paper’s LaTeX sets the labels in its own fonts. save returns an alternative text and a caption for each figure, and set table ... markdown writes the numbers as Markdown tables. splot as gnuplot draws it: a pm3d surface, depth sorted and lit (set pm3d lighting).

The interactive page: each zoom regenerates the tick labels by the same rules as the Fortran side, exact decimals at every scale.

The same run over ssh: foresight --watch -e "set terminal block braille" redraws the terminal in place.

From a solver’s arrays:

program taste
use foresight, only : figure_object, I4P, R8P
implicit none
type(figure_object)    :: fig
real(R8P), allocatable :: t(:)
integer(I4P)           :: i

t = [(0.05_R8P * i, i = 0, 200)]
call fig%set_title('A damped oscillation')
call fig%set_xlabel('time [s]')
call fig%plot(t, exp(-0.3_R8P * t) * cos(2.0_R8P * t), title='u(t)', lw=2.0_R8P)
call fig%plot(t, exp(-0.3_R8P * t), title='envelope', dt=2_I4P)
call fig%save('taste.html')   ! .svg, .pdf, .tex, .txt: the extension picks the format
endprogram taste

or from the log it writes, with a gnuplot script:

set logscale y
set format y '10^{%L}'
plot 'run.dat' using 1:2 with lines title 'continuity', '' using 1:3 with lines title 'momentum'
curl -fsSL https://github.com/szaghi/foresight/releases/latest/download/install.sh | bash
foresight --watch residuals.gp

The one-line installer builds the latest release with FoBiS or fpm and installs it into ~/.local, usable through pkg-config. foresight is also an fpm and a FoBiS dependency.

The installation page’s library example: two panels, three line styles, a log axis with enhanced-text exponents.

A run monitor in the vacuum-fluorescent theme: readouts, segmented bars, residuals.

TeX math in the axis labels and the key, in Latin Modern Math.

An isosurface of a voxel grid (set vgrid, vfill, with isosurface).

A complex function over the plane, coloured by its phase.

A wind rose of sectors.

Two panels across a page, in Latin Modern: a figure a LaTeX paper takes as it is.

The gallery has all 226 cookbook plots, by category, each with its script in the cookbook.

qpdf, pdffonts and pdftotext; foresight is one of three projects with one goal: a Fortran program, from the running solver to its paper, with no runtime but its own.

write, and its pages will read Markdown. figure_info already. foresight builds with FoBiS or fpm, and its only dependencies are my own Fortran libraries (PENF, BeFoR64, FACE, StringiFor), fetched by either. It runs on Linux and other POSIX systems; on Windows, run it in WSL 2. It is available under your choice of license: GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT. The compiled-in fonts keep their own licenses (SIL OFL 1.1, GUST Font License).

Coming next: text placed exactly where gnuplot places it, with equal plot areas, on every device (#6), and whatever the first users find.

Feedback, issues, and contributions are welcome, and in this phase bug reports most of all.

Stefano

── more in #developer-tools 4 stories · sorted by recency
── more on @foresight 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/foresight-fortran-ea…] indexed:0 read:4min 2026-11-28 · —