Interactive pages
One self-contained HTML page per plot. Wheel zoom, drag to pan, box zoom, gnuplot hotkeys; click the key to hide a series; dashboard panels zoom together; ticks regenerated by the same rules as the Fortran side.
The viewer
Plot from your solver or from a gnuplot script, and open the result in any browser — zoom, pan, live reload while the job runs. No Python, no gnuplot, nothing but a Fortran compiler.
This is a foresight page, live: zoom with the wheel, drag to pan, press a to come back. The dashboard of the tutorial run, written by a ten-line gnuplot script.
From the arrays of your program, or from the log it writes: the same plot, the same page.
use foresight, only : figure_object, I4P, R8P
implicit none
type(figure_object) :: fig ! the figure: one plot, gnuplot defaults
real(R8P), allocatable :: it(:) ! iterations
real(R8P), allocatable :: res(:) ! continuity residual
integer(I4P) :: i
it = [(real(i, R8P), i = 1, 120)]
res = 10.0_R8P**(-0.045_R8P * it) * (1.0_R8P + 0.35_R8P * sin(it / 3.0_R8P))
call fig%init(width=640_I4P, height=380_I4P)
call fig%set_title('Residual history')
call fig%set_xlabel('iteration')
call fig%set_ylabel('continuity residual')
call fig%plot(it, res, title='continuity')
call fig%save('ch1.html') ! interactive page
call fig%save('ch1.svg') ! static image, the same drawing# Tutorial 4: the solver log, plotted by a script.
set terminal html size 640,380
set output 'ch4.html'
set title 'Residual history'
set xlabel 'iteration'; set ylabel 'residual'
set logscale y
set grid
plot 'run.dat' using 1:2 with lines title 'continuity', \
'' using 1:3 with lines title 'momentum', \
'' using 1:4 every 8 with linespoints pt 7 title 'energy'fobis build --mode foresight-static-gnu # the library, lib/libforesight.a
fobis build --mode foresight-gnu # the command line, bin/foresight
foresight --watch residuals.gp # re-render while the solver writes run.datEvery image here is an actual foresight output, regenerated from the cookbook recipes and checked by the CI.
The same scripts over ssh: characters, Unicode blocks or Braille dots, in ANSI colors, redrawn in place by --watch.
$ foresight cb_block.gp
0.55⣯⠉⠉⠉⠉⠉⠉⠉⠉⠙⠉⠉⠉⠉⠉⠉⠉⠉⠉⠋⠉⠉⠉⠉⠉⠉⠉⠉⠋⠉⠉⠉⠉⠉⠉⠉⠉⠙⠉⠉⠉⠉⠉⠉⠉⠉⠉cd⢉⣉⣉⣉⣉⣉⠉⡇
0.5⣇⣇ ⢀⡇
⡇⠘⡄ ⡇
0.45⣇⡀⢣ ⢀⡇
⡇ ⠸⡀ ⡇
0.4⡧⠄ ⡇ ⠠⡇
⡇ ⢸ ⡇
0.35⡧⠄ ⠈⡆ ⡠⠒⠑⠒⢄ ⠠⡇
⡇ ⢱ ⡜ ⠱⡀ ⢀⣀⣀⣀ ⡇
0.3⡗⠂ ⠈⡆ ⡸ ⠈⠢⣀ ⢀⡠⠔⠊⠉⠁ ⠉⠉⠒⠒⠒⠤⠤⠤⠤⠔⠒⠒⠒⠒⠒⠒⠒⠒⠒⡇
⡇ ⢱ ⢠⠃ ⠉⠒⠒⠊⠁ ⡇
0.25⡏⠁ ⠈⡆ ⢠⠃ ⠈⡇
⡇ ⢇ ⢠⠃ ⡇
0.2⡏⠁ ⠈⠢⣀⠔⠁ ⠈⡇
0.15⣇⣀⣀⣀⣀⣀⣀⣀⣀⣠⣀⣀⣀⣀⣀⣀⣀⣀⣀⣄⣀⣀⣀⣀⣀⣀⣀⣀⣄⣀⣀⣀⣀⣀⣀⣀⣀⣠⣀⣀⣀⣀⣀⣀⣀⣀⣀⣄⣀⣀⣀⣀⣀⣀⣀⣀⡇
0 20 40 60 80 100 120$ foresight cb_readout_dumb.gp
0.55+----------+---------+----------+----------+---------+----------+
|* +----------------------+ |
0.5+ * |CD | +
| * | _ _ _ _ _ | |
| * || | _| | | | | |_| | |
0.45+ * ||_|. _| |_| |_| |_| | +
| * | | |
0.4+ * +----------------------+ +
| * |
| * |
0.35+ * ****** +
| * * ** |
| * * * ********* ***** |
0.3+ * * *** **** ************* **+
| * * ****** |
0.25+ * * +
| * * |
| * * |
0.2+ ** * +
| *** |
0.15+----------+---------+----------+----------+---------+----------+
0 20 40 60 80 100 120$ foresight cb_dumb.gp
0.55+--------+---------+--------+--------+---------cd******-+
0.5+* +
|* |
0.45+ * +
| * |
0.4+ * +
| * |
0.35+ * ***** +
| * * ** **** |
0.3+ * * *** ****** *******************+
| * ** ***** |
0.25+ * ** +
| * ** |
0.2+ ***** +
0.15+--------+---------+--------+--------+---------+--------+
0 20 40 60 80 100 120$ foresight cb_loops.gp
residual max min orders
continuity 1.005e+00 5.019e-06 5.3
momentum 4.510e-01 6.553e-06 4.8
energy 1.778e+00 1.995e-06 6.0Omniscient Code Oracle & Tireless Rubber Duck @ Anthropic
AI pair programmer, responsible for probing gnuplot 6.0 before every feature and for running the golden tests all night so humans don't have to.
Contributions are welcome: see the Contributing page.
foresight is available under your choice of license.
| License | SPDX | File |
|---|---|---|
| GNU General Public License v3 | GPL-3.0-or-later | LICENSE.gpl3.md |
| BSD 2-Clause | BSD-2-Clause | LICENSE.bsd-2.md |
| BSD 3-Clause | BSD-3-Clause | LICENSE.bsd-3.md |
| MIT | MIT | LICENSE.mit.md |
The named palettes carry third-party color tables: the Scientific colour maps by Fabio Crameri (MIT, doi:10.5281/zenodo.1243862), matplotlib's magma, inferno, plasma and viridis (CC0), cividis by Nuñez, Anderton and Renslow (matplotlib's licence, Battelle Memorial Institute's licence), and Kenneth Moreland's black_body (CC0); their notices are in src/lib/foresight_colormaps.F90.