TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A command line tool that draw plots on the terminal

621 pointsby damirover 2 years ago

35 comments

eigenhombreover 2 years ago
There is, as one might expect, quite a long history of such tools, since text-only interfaces were the norm in the olden days.<p>When I was a young one doing physics in the &#x27;80s, we used CERN&#x27;s HBOOK[1] to do all our (statistical) plotting. Recently while working on a Common Lisp project I had a use for something similar, remembered HBOOK, and &quot;rolled my own&quot;[2] (much simpler version).<p>Yes, a nice clean graph in a GUI or PDF is cleaner, but if you&#x27;re working at the terminal already or in a REPL, it can be nice to just see the output there.<p>At the risk of downvotes: I do wish this particular project didn&#x27;t require a working Ruby &#x2F; Gem installation -- nothing against Ruby, but I&#x27;d be curious if there was an equivalent stand-alone executable written in Go or similar... something like [3]?<p>[1] <a href="https:&#x2F;&#x2F;cds.cern.ch&#x2F;record&#x2F;307945&#x2F;files&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cds.cern.ch&#x2F;record&#x2F;307945&#x2F;files&#x2F;</a> [2] <a href="https:&#x2F;&#x2F;github.com&#x2F;eigenhombre&#x2F;hbook">https:&#x2F;&#x2F;github.com&#x2F;eigenhombre&#x2F;hbook</a> [3] <a href="https:&#x2F;&#x2F;github.com&#x2F;gizak&#x2F;termui">https:&#x2F;&#x2F;github.com&#x2F;gizak&#x2F;termui</a>
评论 #34368838 未加载
评论 #34375388 未加载
评论 #34369537 未加载
评论 #34373570 未加载
yborisover 2 years ago
Looks really great! I love tools that work in the terminal.<p>I used <i>asciichart</i> in my <i>mortgage-and-investments</i> script for the terminal (shows a nice graph).<p><a href="https:&#x2F;&#x2F;github.com&#x2F;whyboris&#x2F;mortgage-and-investments">https:&#x2F;&#x2F;github.com&#x2F;whyboris&#x2F;mortgage-and-investments</a> &lt;-- screenshot there<p><a href="https:&#x2F;&#x2F;github.com&#x2F;kroitor&#x2F;asciichart">https:&#x2F;&#x2F;github.com&#x2F;kroitor&#x2F;asciichart</a> &lt;-- the library I used
评论 #34380128 未加载
评论 #34368714 未加载
db48xover 2 years ago
If you really want to draw plots on the terminal, run `xterm -ti 340` and then use gnuplot, like this:<p><pre><code> gnuplot -e &quot;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)) &#x2F; sqrt(x**2+y**2)&quot;</code></pre>
评论 #34365380 未加载
评论 #34366407 未加载
评论 #34365898 未加载
评论 #34365951 未加载
评论 #34366426 未加载
评论 #34369264 未加载
评论 #34372389 未加载
评论 #34372955 未加载
评论 #34380141 未加载
dima55over 2 years ago
You want feedgnuplot: <a href="https:&#x2F;&#x2F;github.com&#x2F;dkogan&#x2F;feedgnuplot&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;dkogan&#x2F;feedgnuplot&#x2F;</a><p>It gives you all the power of gnuplot. So you can make simple plots in the console, or fancy graphical ones, or output to files on disk or whatever.
评论 #34370528 未加载
评论 #34380165 未加载
somatover 2 years ago
Very nice. For live plots there is also ttyplot.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;tenox7&#x2F;ttyplot">https:&#x2F;&#x2F;github.com&#x2F;tenox7&#x2F;ttyplot</a>
radarsat1over 2 years ago
Would love to see something like this built into tqdm[0]. Being able to attach a graph to the output would be a fantastic complement to postfixing the progress bar with current numbers.<p>[0] <a href="https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;tqdm&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;tqdm&#x2F;</a>
lynx23over 2 years ago
Slightly related<p><a href="https:&#x2F;&#x2F;github.com&#x2F;diagrams&#x2F;diagrams-braille&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;diagrams&#x2F;diagrams-braille&#x2F;</a>
jb3689over 2 years ago
The weakest part about distributing these tools in Ruby for me has been rbenv wiping them away on switches. I rarely switch Ruby versions these days, but this used to be pain all of the time
guntarsover 2 years ago
So many times I&#x27;ve wanted a quick histogram of a list of values to get a feel for their distribution, but it&#x27;s always felt like it&#x27;s too much effort with the tools that I had available to me. This is perfect for it! Would be nice to be able to specify the bin size or clamp the values to a range, but that can be done with other tools in the pipeline.
aumerleover 2 years ago
You have been able to draw plots from proper graphing libraries using actual images for years in terminals that support the kitty graphics protocol. See<p>GNUPlot: <a href="https:&#x2F;&#x2F;sw.kovidgoyal.net&#x2F;kitty&#x2F;integrations&#x2F;#tool-gnuplot" rel="nofollow">https:&#x2F;&#x2F;sw.kovidgoyal.net&#x2F;kitty&#x2F;integrations&#x2F;#tool-gnuplot</a> matplotlib: <a href="https:&#x2F;&#x2F;github.com&#x2F;jktr&#x2F;matplotlib-backend-kitty">https:&#x2F;&#x2F;github.com&#x2F;jktr&#x2F;matplotlib-backend-kitty</a> Julia: <a href="https:&#x2F;&#x2F;github.com&#x2F;simonschoelly&#x2F;KittyTerminalImages.jl">https:&#x2F;&#x2F;github.com&#x2F;simonschoelly&#x2F;KittyTerminalImages.jl</a><p>The kitty graphics protocol is supported in three major terminals these days: kitty, WezTerm, konsole.
评论 #34410640 未加载
rcarmoover 2 years ago
This is pretty amazing, but is there a non-Ruby alternative?
评论 #34376105 未加载
评论 #34366290 未加载
评论 #34365909 未加载
articsputnikover 2 years ago
This is so cool. It reminds me of Markdown and Mermaid (<a href="https:&#x2F;&#x2F;github.com&#x2F;mermaid-js&#x2F;mermaid">https:&#x2F;&#x2F;github.com&#x2F;mermaid-js&#x2F;mermaid</a>), which can do a similar thing within a plain text file. Keep it up; looking forward to trying it out.
earthsciencemanover 2 years ago
This will be the most hideous comment I&#x27;ve ever made on the internet.<p>I would die for something like this to be an emacs package, to be written in elisp. I do all my development and data processing in emacs on remote clusters and it is insanely efficient and quick to iterate. The only thing that slows me down is getting and making plots. I can, of course, but I still mount the drive and transfer plots as compressed images. Which is horrifically inefficient for doing very quick rapid iterations on the processing of data....<p>Of course, the effort to duplicate the functionality of this in elisp that properly displays in the emacs TUI would be herculean. But there&#x27;s no way I can install ruby on my remote clusters :(
评论 #34371259 未加载
H4ZB7over 2 years ago
what&#x27;s the point in all these terminal programs posted here every day? why would i ever draw stuff with text when it&#x27;s just going to be converted back to pixels by the OS anyway? there&#x27;s clearly a bigger reason than just being able to do stuff without the slow desktop environment. but what is it?
评论 #34370662 未加载
评论 #34368768 未加载
评论 #34368852 未加载
评论 #34368726 未加载
评论 #34369973 未加载
two_handfulsover 2 years ago
I feel like an in-terminal plotting tool would be a great fit for nushell (<a href="https:&#x2F;&#x2F;www.nushell.sh" rel="nofollow">https:&#x2F;&#x2F;www.nushell.sh</a>), because they already have the philosophy that tools where possible should return structured data rather than just text.
JoeyBananasover 2 years ago
Drawing graphics in the terminal is trying to use a hammer as a screwdriver. I&#x27;m looking at you, Textualize.
评论 #34372775 未加载
chrisanover 2 years ago
This is great (as is seeing all the other links in this thread for other variations). Makes me want to make a rpi dashboard for a retro &quot;ops view&quot; instead of the fancy&#x2F;pretty graphs in APM tools.<p>Not saying I&#x27;d give those up, but would just a nice lil desktop ornament :)
synergy20over 2 years ago
gnome-terminal really need to support kitty like features, that is, draw images and plots directly inside the terminal, xterm can do that, konsole is adding them, gnome-terminal please add the support so I do not need switch to kitty(which is OK, but)
评论 #34410676 未加载
revskillover 2 years ago
<p><pre><code> series2 = data.series .map { |s| s.map(&amp;:to_f) } .each_slice(2).to_a </code></pre> Should we use data.series.lazy for better memory consumption ?
college_physicsover 2 years ago
I remember trying to display graphics on a VT100 type terminal over a modem. It took forever to render on screen (you could see individual lines being drawn one by one).
hyperificover 2 years ago
How long before someone used this to run Doom in the terminal?
BruceEelover 2 years ago
Pushing the boundaries of what can be done in a term, extremely cool! Output looks really slick too.<p>Could it also be used to draw an AST or a DAG?
评论 #34374463 未加载
aborsyover 2 years ago
How does gnuplot compare with Python’s pyplot or Matlab plots in terms of quality and versatility?
评论 #34372708 未加载
mh-cxover 2 years ago
This looks really nice but I&#x27;m missing specs on the format of the input data.
评论 #34369593 未加载
monkeycantypeover 2 years ago
Is this using braille characters for the scatter plot?
Alifatiskover 2 years ago
Never would have guessed this was written in Ruby, that’s so cool!
jll29over 2 years ago
Elegant, useful and simple - thanks!
tobyhinloopenover 2 years ago
Cute
anthkover 2 years ago
Gnuplot does that too.
评论 #34369770 未加载
folexover 2 years ago
awesome!
kaba0over 2 years ago
Cool, but.. why?<p>I do like CLI apps, but due to the non-standard state of GUI development we reach for very inefficient hacks to display basically pixel data in a fundamentally text-based medium. I would much prefer well-integrated actual GUIs using more than 100x100 pixels.<p>Edit: I don’t really have a problem with this specific program. My point is more general in that we perhaps have the wrong abstraction level for our GUI programs. Those should be standardized and cross platform as well besides supporting remote access .
评论 #34366004 未加载
评论 #34365949 未加载
评论 #34365752 未加载
评论 #34365730 未加载
评论 #34366803 未加载
评论 #34367196 未加载
jesusofnazarathover 2 years ago
This is great thanks. I never could figure out gnuplot, this is way easier to use and just does what you want!! Thanks so much!
jwmozover 2 years ago
Can you make this for Python pretty please?
评论 #34366104 未加载
评论 #34374186 未加载
评论 #34373132 未加载
评论 #34365995 未加载
majkinetorover 2 years ago
Gorgeious.<p>I would even use this just to be cool in the public :)<p>As a realted note, here is one similar thing in Powershell: <a href="https:&#x2F;&#x2F;github.com&#x2F;PrateekKumarSingh&#x2F;Graphical">https:&#x2F;&#x2F;github.com&#x2F;PrateekKumarSingh&#x2F;Graphical</a>
zokierover 2 years ago
Terminal is not a graphical environment so why try to make it into one? Isn&#x27;t the point of terminal to escape the graphics-riddled world
评论 #34365678 未加载
评论 #34365573 未加载
评论 #34365826 未加载
评论 #34365723 未加载
评论 #34365402 未加载
评论 #34368260 未加载
评论 #34365374 未加载