News for hackers. Stuff that matters.
Re:Unicode-based scientific plotting for working in the term... by charlesdaniels on Saturday June 06, 2020 @11:57AM (#23440048)
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 term... by dheera on Saturday June 06, 2020 @02:12PM (#23441148)
I wrote a generic terminal graphics library that uses Unicode Braille with the option of ASCII fallback: https://github.com/dheera/python-termgraphics

I was thinking about adding sixel support to this to have a universal graphics library that intelligently uses the best method available., but never got around to it yet.

Re:Unicode-based scientific plotting for working in the term... by fishmaster on Saturday June 06, 2020 @01:14PM (#23440686)
This looks pretty cool. Why isn't this more popular?
Re:Unicode-based scientific plotting for working in the term... by dheera on Saturday June 06, 2020 @02:10PM (#23441134)
Most of the "default" terminal apps (e.g. gnome-terminal) don't support sixel.
Re:Unicode-based scientific plotting for working in the term... by andi999 on Saturday June 06, 2020 @02:12PM (#23441149)
What terminal do I need to see these images. I am confused.
Re:Unicode-based scientific plotting for working in the term... by charlesdaniels on Saturday June 06, 2020 @02:21PM (#23441217)
The libsixel website lists several that support it. Xterm can support this in VT430 emulation mode, but support needs to be enabled at compile time.
Re:Unicode-based scientific plotting for working in the term... by sprash on Saturday June 06, 2020 @07:09AM (#23438350)
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 using "convert image.png sixel:- > image.six"

Personally I think sixels are genius should be used much more often.

Re:Unicode-based scientific plotting for working in the term... by brutt on Saturday June 06, 2020 @10:36AM (#23439464)
Sixels will be added to libvte (gnome-terminal): https://gitlab.gnome.org/GNOME/vte/-/issues/254
Re:Unicode-based scientific plotting for working in the term... by iso-8859-1 on Saturday June 06, 2020 @04:15PM (#23441916)
Great news! I think we may finally see a resurgence. It will be well supported on mainstream Linux, and given that the web is getting so heavy-weight, this will offer a solid alternative for graphics that you can rely on. Libvte is very popular.
Re:Unicode-based scientific plotting for working in the term... by petepete on Saturday June 06, 2020 @07:18AM (#23438388)
GNUPlot and XTerm also support Tektronix, there's lots of info in this older discussion.

https://news.ycombinator.com/item?id=7776904

Re:Unicode-based scientific plotting for working in the term... by mongol on Saturday June 06, 2020 @07:24AM (#23438406)
The Kitty terminal author also published a "terminal graphics protocol". I don't know what other terminal supports it, however.

https://sw.kovidgoyal.net/kitty/graphics-protocol.html

Re:Unicode-based scientific plotting for working in the term... by dTal on Saturday June 06, 2020 @09:26AM (#23439024)
>it packs better than png when used in conjunction with the bzip2 packer.

Cute! But is it fair? I don't think it's lossless - the color depth is much reduced.

Re:Unicode-based scientific plotting for working in the term... by sprash on Saturday June 06, 2020 @10:29AM (#23439422)
I took the reduced color depth into consideration. However on second glance it seems like Imagemagick does not compress PNG very efficiently with default settings. After recompressing with zopflipng PNG was easily able to beat bzip2 packed sixels. Results for 256 color 512x512 Lenna:

Sixel + bzip2: 245K

PNG Imagemagick: 467K

PNG Zopfli 10 Iterations: 188K

Re:Unicode-based scientific plotting for working in the term... by iso-8859-1 on Saturday June 06, 2020 @04:13PM (#23441903)
I used your ImageMagick command, but the resulting image is very bright and almost invisible. I tried disabling Unicode using +u8, but that didn't work. I tried mlterm, that worked.
Re:Unicode-based scientific plotting for working in the term... by sprash on Sunday June 07, 2020 @01:48PM (#23449135)
I forgot to tell that you have to enable 256 colors as well. Put this into your .Xresources:

    XTerm.*.decTerminalID: vt340
    XTerm.*.numColorRegisters: 256
And refresh with

    xrdb -merge $HOME/.Xresources
It should work now.
Re:Unicode-based scientific plotting for working in the term... by leephillips on Saturday June 06, 2020 @11:37AM (#23439882)
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 term... by dorfsmay on Saturday June 06, 2020 @10:37AM (#23439469)
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).
Re:Unicode-based scientific plotting for working in the term... by KenoFischer on Saturday June 06, 2020 @10:44AM (#23439530)
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 term... by dorfsmay on Saturday June 06, 2020 @10:52AM (#23439580)
Are they using a similar API/standard?
Re:Unicode-based scientific plotting for working in the term... by kps on Saturday June 06, 2020 @12:05PM (#23440114)
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.
Re:Unicode-based scientific plotting for working in the term... by tempodox on Saturday June 06, 2020 @10:44AM (#23439527)
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 term... by kps on Saturday June 06, 2020 @11:54AM (#23440008)
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 term... by z3t4 on Saturday June 06, 2020 @02:39PM (#23441351)
I heard they have something similar at Cern and it also has clickable links and universal resource locators.
Re:Unicode-based scientific plotting for working in the term... by visviva on Saturday June 06, 2020 @10:04AM (#23439249)
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.
Re:Unicode-based scientific plotting for working in the term... by ViralBShah on Saturday June 06, 2020 @11:38AM (#23439890)
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 term... by vok on Saturday June 06, 2020 @11:26AM (#23439801)
I also like that I can incorporate plots into my plain-text notes files.
Re:Unicode-based scientific plotting for working in the term... by lsllc on Saturday June 06, 2020 @06:44PM (#23442975)
This is awesome. When I build my spaceship, it's going to have a command line interface and I'll use this to display pertinent spaceship-data, such as gravitational pull of nearby black holes, tachyon levels, and warp signatures etc.

Can't safely use a touchscreen or mouse when all hell breaks loose in space!

Re:Unicode-based scientific plotting for working in the term... by antirez on Saturday June 06, 2020 @04:08PM (#23441881)
Trivia: Redis uses a similar technique (Braille unicode points) to show the Redis 5 LOLWUT. http://antirez.com/news/123
Re:Unicode-based scientific plotting for working in the term... by michaelhoffman on Saturday June 06, 2020 @10:29AM (#23439414)
This is great! Anyone know of anything like this for Python or R?
Re:Unicode-based scientific plotting for working in the term... by ianhorn on Saturday June 06, 2020 @02:15PM (#23441169)
I made a dead simple, somehow surprisingly useful one for python back in 2014. I still use it for quick investigations all the time.

hipsterplot: https://github.com/imh/hipsterplot

Re:Unicode-based scientific plotting for working in the term... by dheera on Saturday June 06, 2020 @02:09PM (#23441115)
I also wrote a more generic Python terminal plotting library: https://github.com/dheera/python-termgraphics

For robotics people -- the above is used in rosshow: http://github.com/dheera/rosshow

Re:Unicode-based scientific plotting for working in the term... by metaodi on Saturday June 06, 2020 @11:31AM (#23439838)
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 term... by foob on Saturday June 06, 2020 @01:47PM (#23440925)
It's not unicode, but there's also sixelplot [1] which allows matplotlib plotting in a terminal using sixel. The underlying pysixel library [2] unfortunately doesn't support Python 3.7+ however.

[1] https://github.com/kktk-KO/sixelplot

[2] https://github.com/saitoha/PySixel

Re:Unicode-based scientific plotting for working in the term... by iso-8859-1 on Saturday June 06, 2020 @03:59PM (#23441830)
There is a PR that fixes it for 3.7, it needs review: https://github.com/saitoha/PySixel/pull/5
Re:Unicode-based scientific plotting for working in the term... by SubiculumCode on Saturday June 06, 2020 @05:25PM (#23442356)
Honest question: Why would I ever want/need to plot data in the R console, and not in a R graphics window?
Re:Unicode-based scientific plotting for working in the term... by tejtm on Saturday June 06, 2020 @06:23PM (#23442799)
the "work" you are doing is via ssh into a big box behind gateway/jumphost with peculiar limitations on ports & access from the data gravity well which is your bog standard asymmetric home isp ; annoying but you need to do anyway because the remote hardware has more bandwidth, memory, cores and storage than a stack of laptops taller than you... I could go on but lets just acknowledge not every task fits in a prepackaged shiny solution.