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.

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.

Lines, points and error bars ​

Bars and statistics ​

Areas and shapes ​

Heatmaps and images ​

Polar and radial charts ​

Dashboards of the 1980s ​

In the terminal ​

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.6⡏⠉⠉⠉⠉⠉⠉⠉⠉⠙⠉⠉⠉⠉⠉⠉⠉⠉⠉⠋⠉⠉⠉⠉⠉⠉⠉⠉⠙⠉⠉⠉⠉⠉⠉⠉⠉⠉⠋⠉⠉⠉⠉⠉⠉⠉⠉⠙cd⢉⣉⣉⣉⣉⣉⠉⡇
     ⣇                                                        ⡇
     ⡏⢆                                                       ⡇
  0.5⡏⠙⡄                                                     ⠈⡇
     ⡇ ⢣                                                      ⡇
     ⡇ ⠈⡆                                                     ⡇
  0.4⡏⠁ ⢱                                                    ⠈⡇
     ⡇  ⠈⡆          ⢀⠔⠒⠒⢄⡀                                    ⡇
  0.3⣇⡀  ⢸         ⡔⠁    ⠈⠢⣀        ⢀⣀⡠⠤⠤⠤⠤⣀⣀⣀        ⢀⣀⣀⣀⣀⣀⣀⣀⡇
     ⡇    ⢇      ⢀⠜         ⠑⠢⠤⣀⡠⠤⠒⠊⠁         ⠉⠉⠉⠉⠉⠉⠉⠉⠁       ⡇
     ⡇    ⠘⡄    ⢀⠎                                            ⡇
  0.2⣇⡀    ⠘⡄  ⡠⠊                                            ⢀⡇
     ⡇      ⠘⠢⠒⠁                                              ⡇
     ⡇                                                        ⡇
  0.1⣇⣀⣀⣀⣀⣀⣀⣀⣀⣠⣀⣀⣀⣀⣀⣀⣀⣀⣀⣄⣀⣀⣀⣀⣀⣀⣀⣀⣠⣀⣀⣀⣀⣀⣀⣀⣀⣀⣄⣀⣀⣀⣀⣀⣀⣀⣀⣠⣀⣀⣀⣀⣀⣀⣀⣀⣀⡇
     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   10    20   30   40    50   60   70    80   90   100   110  120
text
$ foresight cb_dumb.gp

  0.6+--------+---------+--------+---------+--------+cd******-+
     |                                                        |
     |*                                                       |
  0.5+*                                                       +
     | *                                                      |
     |  *                                                     |
  0.4+  *                                                     +
     |   *          ******                                    |
  0.3+   *         **    ***        **********        ********+
     |    *      **         *********         *********       |
     |    **    **                                            |
  0.2+     **  **                                             +
     |      ***                                               |
     |                                                        |
  0.1+--------+---------+--------+---------+--------+---------+
     0       20        40       60        80       100       120

Authors ​

Copyrights ​

foresight is distributed under the GNU General Public License v3.