Skip to content

FORESIGHTgnuplot-like plots from pure Fortran

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.

FORESIGHT, Fuji plotted on two axes with the sun ahead of its slopeFORESIGHT, Fuji plotted on two axes with the sun ahead of its slope

One run, one page ​

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.

wheel: zoom · drag: pan · right drag: box · a resetopen page ↗

Quick start ​

From the arrays of your program, or from the log it writes: the same plot, the same page.

fortran
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
gnuplot
# 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'
bash
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.dat

Every image here is an actual foresight output, regenerated from the cookbook recipes and checked by the CI.

Data and columns ​

Axes, ticks and key ​

Lines, points and error bars ​

Bars and statistics ​

Areas and shapes ​

Heatmaps and images ​

3D plots ​

Polar and radial charts ​

Dashboards of the 1980s ​

Text terminals ​

The same scripts over ssh: characters, Unicode blocks or Braille dots, in ANSI colors, redrawn in place by --watch.

text
$ 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
text
$ 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
text
$ 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
text
$ 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.0

For a paper ​

From Fortran ​

Authors ​

Stefano Zaghi

Stefano Zaghi

Chief Yak Shaver & Serial Library Resurrector

Trusts no plotting tool he has not rewritten, and has now rewritten one.

Claude

Claude

Omniscient 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.

License ​

foresight is available under your choice of license.

LicenseSPDXFile
GNU General Public License v3GPL-3.0-or-laterLICENSE.gpl3.md
BSD 2-ClauseBSD-2-ClauseLICENSE.bsd-2.md
BSD 3-ClauseBSD-3-ClauseLICENSE.bsd-3.md
MITMITLICENSE.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.

© Stefano Zaghi

Released under the GPL v3, BSD 2-Clause, BSD 3-Clause or MIT License.