Nice graphs for the toplevel

If you are using the kitty terminal, you can get nice graphs at the toplevel:


dot(Prg) :-
    Cmd='dot -Tpng  | kitty +kitten icat --stdin yes',
    setup_call_cleanup(
       open(pipe(Cmd),write,Stream,[]),
       write(Stream,Prg),
       close(Stream)
    ).

plot(Plot) :-
    format(string(Cmd),"
        cat <<EOF | gnuplot
        set terminal pngcairo enhanced font 'Fira Sans,10'
        set autoscale
        set samples 1000
        set output '|kitty +kitten icat --stdin yes'
        set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb \"#fdf6e3\" behind
        plot ~w
        set output '/dev/null'
EOF",[Plot]),
    shell(Cmd).

How it looks:

EDIT: you need to have graphviz and gnuplot installed to make it work.

3 Likes

SWISH in the terminal :slight_smile: Note that the Qt swipl-win console by @CapelliC can do some of this as well if I recall correctly. Unfortunately Iā€™m addicted to terminator