8

I have a bunch of binaries that output data like this:

-0.002019
-0.000790
0.000158
0.001539

It's just a bunch of numbers that I want to plot on a y-axis with equal spacing in the x-axis.

The output is actually a couple thousand lines long.

I need a simple way of piping this to something that plots it, like so:

./program_dumping_numbers | ??? # a simple window of the plot pops up!
1
  • 2
    Take a look at Gnuplot.
    – Cyrus
    Dec 21, 2015 at 22:36

4 Answers 4

9

Try the following:

./program_dumping_numbers | gnuplot -p -e 'plot "/dev/stdin" using 0:1 with lines'

where 0 is virtual line number, 1 is column number, "with lines" means that continues line instead of just points

1
  • hey, you forgot a ' there! :) but this is exactly what I needed. Thanks.
    – m fran
    Dec 23, 2015 at 14:00
7

I would highly recommend ttyplot, you can build live graphs directly in the terminal, reading data from STDIN

enter image description here

3

Here are some options. I liked datadash the best. None of them work that well.

ttyplot

datadash --average-line # install: https://github.com/keithknott26/datadash/issues/5
feedgnuplot --stream --terminal 'dumb 120,30' --lines # outputs new plots instead of updating the creen.
# `gnuplot -e 'set terminal'` for a list of outputs
asciigraph -r # usable but no stats and wrong height detection. No fixed scale. github.com/guptarohit/asciigraph/cmd/asciigraph
2

An old way to do it is with plotutils [1] installed.
(under Ubuntu you can install with sudo apt-get install plotutils).

With the command

./program_dumping_numbers | graph -T X

it will plot your data in an X windows, instead with

./program_dumping_numbers | graph -T png > Myfile.png

it will create a png file. Type info plotutils for further references.

Of course you can use gnuplot with a script that read from the standard input and all the features you want. (select as file input "/dev/stdin" )

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .