Live data from Hacker News

Unicode-based scientific plotting for working in the terminal

github.com

11–20 of 37 posts

Re: Unicode-based scientific plotting for working in the terminal

#11

As somebody who grew up during the semi-graphic era, it makes me sad that we still use a 30 year old standard for terminals and cannot do direct plot in the main terminal (as opposed to the Tektronix separate window).

I was thinking something similar. Looking at this makes me wish a terminal app could just embed a PNG or whatever in its output.

Re: Unicode-based scientific plotting for working in the terminal

#12

As somebody who grew up during the semi-graphic era, it makes me sad that we still use a 30 year old standard for terminals and cannot do direct plot in the main terminal (as opposed to the Tektronix separate window).

Several terminals (kitty, iTerm2) do support plotting right into the terminal, but this is still sometimes useful if you don't want to load a while graphics stack just to do a simple plot.

Re: Unicode-based scientific plotting for working in the terminal

#13

As somebody who grew up during the semi-graphic era, it makes me sad that we still use a 30 year old standard for terminals and cannot do direct plot in the main terminal (as opposed to the Tektronix separate window).

Several terminals (kitty, iTerm2) do support plotting right into the terminal, but this is still sometimes useful if you don't want to load a while graphics stack just to do a simple plot.

Are they using a similar API/standard?

Re: Unicode-based scientific plotting for working in the terminal

#14
post #6

This is one of my favorite Julia packages! A fast plotting utility that outputs right to the terminal is one of those things that I didn't realize I needed until I found it.

I also like that I can incorporate plots into my plain-text notes files.

Re: Unicode-based scientific plotting for working in the terminal

#15

This is great! Anyone know of anything like this for Python or R?

I guess plotille (https://github.com/tammoippen/plotille) is the closest match for python. And maybe termgraph (https://github.com/mkaz/termgraph) is kind of similar.

Re: Unicode-based scientific plotting for working in the terminal

#16
post #2

I recently found out that XTerm supports sixels natively if started with the "-ti 340" option. For example gnuplot can make use of that feature using the command "set terminal sixlegd". It turns out because of the way sixels are encoded (six vertical pixels in a row using bitplanes) it packs better than png when used in conjunction with the bzip2 packer. Every image can simply be encoded to sixel with imagemagick usi…

That should be "sixelgd", of course. And there is the classic "dumb" terminal, that plots to any text terminal, optionally using ansi escape codes for color.

Re: Unicode-based scientific plotting for working in the terminal

#17
post #6

This is one of my favorite Julia packages! A fast plotting utility that outputs right to the terminal is one of those things that I didn't realize I needed until I found it.

Yes. Some people think this is a gimmick. But it is actually quite a bit useful. Especially, when in the middle of a session, I often do not want to move my hands from the keyboard to the mouse to close windows that plotting tools open, or move my gaze. It's not often that I work like this, but I like it that I can for the times I need to.

Having inline plots in the terminal - especially things like histograms which just work - is often quite handy. And it just works over an ssh connection.

Also, recently, Julia changed its sparse matrix display to show a picture of the sparse matrix (spy plot) using braille characters!

  julia> a = sprand(20,20,0.2)
  20×20 SparseMatrixCSC{Float64,Int64} with 67 stored entries:
  ⠀⠀⠁⠐⠄⠋⠡⠀⠐⡀
  ⢳⠁⠡⠈⠂⠀⠀⠁⢡⠑
  ⡠⠋⢠⡀⢄⢀⢀⠄⠈⠈
  ⠩⠄⠐⠨⠈⠀⠆⠂⠨⠤
  ⠄⠄⢀⢂⠠⢀⠀⠂⠆⠂

Re: Unicode-based scientific plotting for working in the terminal

#18

As somebody who grew up during the semi-graphic era, it makes me sad that we still use a 30 year old standard for terminals and cannot do direct plot in the main terminal (as opposed to the Tektronix separate window).

I was thinking something similar. Looking at this makes me wish a terminal app could just embed a PNG or whatever in its output.

The OSC 1337 protocol pioneered by iTerm2 does exactly that. You'll have to check whether your preferred terminal supports it (I known mlterm does), either from documentation or just trying it¹.

Also, some terminals support the DEC SIXEL protocol² (again, I know mlterm does).

¹ https://www.iterm2.com/utilities/imgcat

² https://en.wikipedia.org/wiki/Sixel

Edit: I couldn't find a simple SIXEL sample — you'd think one of the popular sixel libraries would have some in unit tests, but no. So for the purpose of this thread (but maybe not forever, hence /tmp/),

    curl https://datatravelandexperiments.com/kps/tmp/example.sixel
    curl https://datatravelandexperiments.com/kps/tmp/example.osc1337
Those are such that output directly to the terminal will produce an image if that format is supported (and probably nothing if not, but I'm not making promises).

Re: Unicode-based scientific plotting for working in the terminal

#19
Every time I see these things, I wish Sixel graphics[0] were better supported, or else some more modern alternative.

Being able to use GNUPlot with Sixel output or tools like lsix[1] is really cool! I think if support / libraries / knowledge about Sixels was more widespread, we would see some really nifty terminal applications cropping up.

0 - https://saitoha.github.io/libsixel/

1 - https://github.com/hackerb9/lsix

Re: Unicode-based scientific plotting for working in the terminal

#20

Earlier quoted context omitted.

Several terminals (kitty, iTerm2) do support plotting right into the terminal, but this is still sometimes useful if you don't want to load a while graphics stack just to do a simple plot.

Are they using a similar API/standard?

Most use OSC 1337 (originally from iTerm2) and/or SIXEL (originally from DEC -ades ago). At a quick glance, kitty appears to have NIHed their own instead.
Post reply on HN