gnuplot -e "set terminal sixelgd;set hidden3d;set view 60, 30, 1, 1.1;set samples 50, 50;set isosamples 52, 52;set contour base;set cntrparam order 8;set cntrparam bspline;splot [-12:12.01] [-12:12.01] sin(sqrt(x**2+y**2)) / sqrt(x**2+y**2)" gnuplot -e "set terminal sixelgd;set hidden3d;set view 60, 30, 1, 1.1;set samples 50, 50;set isosamples 52, 52;set contour base;set cntrparam order 8;set cntrparam bspline;splot [-12:12.01] [-12:12.01] sin(sqrt(x**2+y**2)) / sqrt(x**2+y**2)"https://github.com/saitoha/libsixel
contains img2sixel, which lets you dump images to the terminal. It can also do animated GIFs.
Video:
https://github.com/saitoha/FFmpeg-SIXEL
GUI apps:
https://github.com/saitoha/SDL1.2-SIXEL
and more, linked from the libsixel repository.
There's also the Kitty graphics API but I've never actually seen it work on any machines I've used Kitty, Wezterm, etc. that supposedly support it.
(The expected use case - generating quick plots on a remote machine; I usually just scp them back, but with this, and the new-to-me matplotlib integration, i can just have them show up in the terminal without having to launch a notebook or fight with X). Well supported by iterm2 on mac as the terminal side.
[1] https://www.dim13.org/teapot [2] https://jirkasnotes.wordpress.com/2019/07/17/xterm-does-grap...
You can even compose the gnuplots with the scrollback patch to scroll back in your gnuplots. I use this all the time. In fact, I just have GNUTERM="sixelgd enhanced linewidth 3 fontscale 2 size 1600,900 truecolor" in my environment variables.
Combined with shell history (or gnuplot history) this makes for a rudimentary "notebook"-like interface, but with a log instead of a file to record state.
There’s also kitty that has some improvements over sixel[2]
You could also use the techniques of [1] but use `set term png` and `set output "/tmp/pl.png"` instead and then auto-launch any image viewer on "/tmp/pl.png" instead of relying on terminal graphics at all.
I've always avoided gnuplot because it has looked pretty hard to get anything useful out of. But uplot looks much more approachable. Just piping some data to "uplot hist --nbins 20" is something I'll remember.
gnuplot> plot '<pipeline'
It just uses system(3) for "pipeline". So, technically you could have a whole script in there with maybe tricky gnuplot-quoting/escaping of shell stuff.You do have 2 different history logs this way - the shell one and the plot one while the uplot way is integrated.
If you really want integrated, you could drive gnuplot with temp files, though each shell command-line would probably have to pass a lot of controls. E.g.,
#!/bin/sh
cat > /tmp/dat # should use mktemp -d
cat > /tmp/p.gpi <<-EOF
plot '/tmp/dat' $*
EOF
gnuplot /tmp/p.gpi
and then $ seq 1 10 | gpl with lines
It is an exercise for the reader (well, it has probably been done N times...) to harden the temp paths, clean up afterward, generalize to source user/maybe per-directory `foo.gpi` setup and so on.In the unlikely event temp space is actually any sort of issue then you might be able to use mkfifo (I've never tried) or else generate a .gpi script that uses the plot '<string' syntax escaping `string`.
seq 1 10 | gnuplot -e "plot '<cat' with lines"
[1] https://news.ycombinator.com/item?id=34365290 gnuplot -e "set terminal sixelgd;plot '<&3' with lines" 3< <(seq 1 10)
Good luck remembering that! seq 1 10 | gnuplot -e 'plot "-"' ls -l \
| awk '$5 < 100000 {print $5}' \
| feedgnuplot \
--histo 0 \
--binwidth 5000 \
--xlabel 'File size (bytes)' \
--ylabel Frequency \
--terminal 'dumb 120 40' \
--unset grid
45 +-----------------------------------------------------------------------------------------------------------+
| * * + + + + + + + |
| * * |
| * * |
40 |-+* * +-|
| * * |
| * * |
| * * |
35 |*** * +-|
| * * |
| * * |
| * * |
30 |-+* * +-|
| * * |
| * * |
| * * |
25 |-+* * +-|
| * * |
| * * |
20 |-+* * +-|
| * * |
| * * |
| * * |
15 |-+* * +-|
| * * |
| * * |
| * * |
10 |-+* * +-|
| * * |
| * * |
| * * |
5 |-+* ******** +-|
| * * * ******** |
| * * ******** ********************** ******** * |
| * * + * * + * * + * ******* * + * + + ******** |
0 +-----------------------------------------------------------------------------------------------------------+
0 10000 20000 30000 40000 50000 60000 70000 80000
File size (bytes)
Usually you want graphical output, but it does fine in asciiFeedgnuplot is really slick.
https://github.com/dkogan/feedgnuplot
It's in the debian repos too.
How does it do this?
One weird thing seems to be that it doesn't support zooming in/out the same way the regular text does.
No, for the VT340 they devised a set of escape sequences for encoding bitmaps called Sixels; each character encodes a vertical stripe of six pixels. They used it both for displaying graphics and printing. They also did a vector graphics system called ReGIS a few years earlier.
My favourite use of gnuplot, over ssh, is to plot ascii, just like the presented tool does. Just use
set terminal dumb size `tput cols` `tput lines`Nothing. Xterm is awesome!
And even if xterm is an older program, it seems to be just as actively developed as gnome-terminal. See the changelogs for each:
https://invisible-island.net/xterm/xterm.log.html
https://gitlab.gnome.org/GNOME/vte/-/commits/master
The second link points to libvte, which is the terminal engine behind gnome-terminal where the actual terminalling happens. The changes to gnome-terminal itself are mostly translations and uninteresting desktop stuff:
https://gitlab.gnome.org/GNOME/gnome-terminal/-/commits/mast...
You can read here an explanation of how xterm handled ill-formed utf8 characters in 1999: https://www.invisible-island.net/xterm/bad-utf8/
Meanwhile Gnuplot supports a wide variety of “terminals”, many of which are just outputs to files of various types, some of which are GUIs, others of which are for actual terminals, like “dumb” (ordinary printable characters), “tek40” and “xterm” which use a protocol invented for Tektronix terminals, “sixelgd” which uses the sixel protocol from the VT340, half a dozen types of printers, etc.
But nobody has added one for the Kitty protocol, so it doesn’t work there. The downsides of inventing something new I suppose; the existing software doesn’t automatically support it, someone has to go around and add that support.
https://github.com/dkogan/feedgnuplot
It's in the debian repos so you can pull it if you're in a debian derivative too, like Ubuntu.