I was wondering if there are any generic plotting tools available in the unix toolbox?
By plotting I mean simple bars or things you see in many curses based utilities.
And by unix toolbox I mean things that you can pipe data into them using standard unix conventions.

I need to count somethings in log files (that I am monitoring with tail -F or something) and plot live ratios of things (like percent errors or warnings).


You're looking for gnuplot, with the option terminal set to dumb.

Not my first choice, because I have ROOT on all my machines, but a reliable, ubiquitous standby.

Cernlib's PAW could also do ASCII output, though you'd have to be pretty brave to actually use it as it appears to assume that you have a 132 column fan-fold terminal.

  • ...The development and support for CERNLIB has been discontinued. Libraries will be continued to be provided "as is", alerting? What is the benefit of using Cernlib's PAW instead of R Sweave Latex for example? Never heard of this, generic tool?! I used gnuplot before R Sweave Latex, I find the latter much more convenient to use -- everything in one text-file, including pictures. Can you do this with gnuplot? – user2362 Dec 18 '11 at 2:54
  • @hhh You'll note the tense of "Cernlib's PAW could also do", though people still use it because there is a great deal of mature code out there. – dmckee --- ex-moderator kitten Dec 18 '11 at 3:31
  • very well but what is the added part for? "132 column fan-fold terminal", what is it? For dot-matrix printers? So this is some very old project?! Sorry your answer is too age-obfuscated, "[n]ot my first choice" with gnuplot? Takes me time to understand what you are meaning and writing. Why gnuplot? – user2362 Dec 18 '11 at 3:44
  • The ASCII output mode for PAW was best described as "clunky". By the time I was using cernlib it was native on X and could write directly to postscript or encapsulated postscript which is what we used, however, parts of it can trace their roots to code laid down in the early 1960's. The assumption seem to have been that you have a hard copy terminal; many of those used a 132 character wide format with alternating light and dark bands to make them easy to read. Old enough geeks will all be able to remember the stuff (you still saw it occasionally as late as 1980). – dmckee --- ex-moderator kitten Dec 18 '11 at 3:58
  • 1
    set term dumb to plot ascii – kev Dec 19 '11 at 15:14

You can use R which can produce you some pretty nice graphs and do lots of statistical analysis on your data. This blog post shows you a way to do it.

Similarly, you can use gnuplot see here and here

  • thanks, but I don't want to use any GUI, not for writing the code nor for showing the plots, I want to do it entirely in the terminal. Besides, I'd rather be able to run it without any need to sudo (for installation of anything). – Ali Dec 16 '11 at 15:36
  • @Ali: Look at the following blog post: r-bloggers.com/ascii-scatterplots-in-r – Sardathrion - against SE abuse Dec 16 '11 at 15:40
  • thanx, I had no idea, I need to try this, although I'v never used R but should be easy for mp simple use case. – Ali Dec 16 '11 at 15:43

"Generic plotting tools available in the unix toolbox" is probably every basic Un*x tool, you need to combine tools to create things. I love to combine Latex, R and Sweave! The term "logs" leaves the question a bit open but apparently by purpose, notice the term "generic". So nothing about pre-processing with AWK/SED/etc and only about plotting coming in text-files. Have fun!

enter image description here

$ mkdir Pictures
$ R CMD Sweave paper.Rnw 
Writing to file paper.tex
Processing code chunks with options ...
 1 : term verbatim

You can now run (pdf)latex on 'paper.tex'
$ pdflatex paper.tex 3&>/dev/null

$ evince paper.pdf 


$ cat paper.tex

\usepackage[T1]{fontenc}    % intended quotes



                # Demand/Supply example
plot(x,y-2, type='l', ylab='Price', xlab="Quantity")

title(main="Examples by HHH for R Sweave Latex")

hist(rnorm(100))        # histogram example
plot(sin(1:1E3),cos(1:1E3)) # circle example
plot(sin(1:1E3),1:1E3)      # sin example


Now the next puzzle is accessibility (supposing the op wants ASCII output, not just generic tool). Sorry I do not yet have an answer for it but I will list below info for further exploration.

Just thinking aloud: choose raster image format such as TIFF and then just print evevery 100th column or s/thing like that to see it. Sorry just speculating but I know that TIFF is a de facto raster image format for all kind of archival purposes -- I do not know yet exactly how the OCR engines, such as Tesseract, handle them but but here the problem is easy because you can skip a lot of stuff in the preprocessing of the image -- because we do know how R generates them. Someone got an idea how do this? Or am I reinventing the wheel? At the simplest, pick out a tool that generates hings to ASCII, a bit restrictive to be "generic".


  1. Which tools for ASCII portfolio visualization?
  • Read the question carefully (and the comments where it is made more explicit). The OP want to display results in the terminal. – dmckee --- ex-moderator kitten Dec 18 '11 at 3:28
  • @dmckee: yes but op requires also "generic" tool?! Now this is hard one because I think it infers OCR -based probs, not sure whether op realizes it. – user2362 Dec 18 '11 at 4:06
  • By "generic" I mean, multipurpose tools, things like awk and sed which are not "specific", not designed for a specific use case. Sorry if it's confusing. basically I want to make very simple bar plots in the terminal. That's all. – Ali Dec 18 '11 at 18:02
  • @Ali: stop explaining. You command, we answer -- and the best answer wins. My answer works except "ASCII outputting". Your question is crystal clear but at this time I cannot help you further -- do not care about people having different views, just relax -- someone will sooner or later solve this. I am looking for a solution to similar problem likewise so perhaps we will ... not sure whether we have to dig into OCR engines to solve this but I do think this question is still "unsolved", will look for this... – user2362 Dec 19 '11 at 1:43

You can just pipe your numeric output to a simple perl snippet. For example, here's a test program (in bash) that just outputs increasing numbers:

(i=0; while true; do sleep 1; echo $i; i=$(( $i + 3 )); done)

Assuming I'm interested in a range of values from 0 to 20, and I have a terminal 80 characters wide, I'll do:

[above snippet] | perl -ne '$min=0; $max=20; $w=80; use POSIX; $d=ceil(log($max)/log(10)); $w-=$d; $v=$_<$min?0:$_>$max?$max:$_; $s=$w*$v/($max-$min); $bar=join("", ("*")x$s); $bar=~s/.$/|/ if $v==$max; print sprintf("%${d}d ",$_)."$bar\n";'

 3 ***********
 6 ***********************
 9 ***********************************
12 **********************************************
15 **********************************************************
18 **********************************************************************
21 *****************************************************************************|
24 *****************************************************************************|

Something like this will work on just about any linux system, and the output and parameters are easy to tweak. The overhead compared to using something like gnuplot is miniscule.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.