Show HN: Flexible command line tool to create graphs from CSV data
github.com
github.com
I’ve started using gnuplot a lot after hearing Brendan Gregg mention it a few times. It fills a great niche for making decent graphs without having to write code.
And, yeah I get that “pretty” shouldn’t be the absolute aim of a plot, but it is a nice addition.
I called the apcupsd api from the command line and output some stats to a file that I'd formatted into columns using awk/grep, I then found that I could configure gnuplot to draw a graph from this file, and then update itself automatically as the file changed.
All in all, it took me 10 minutes to put together having not used gnuplot before and did exactly what I needed. I could watch the graph update every few seconds/minutes and keep an eye on what was happening, and because I had written the data to a file first, I could always go back and re-plot it later if I had found anything interesting to re-plot for.
End result; UPS is dead, get a new one :D
It uses matplotlib to generate the graphs, which can save svg files though. This sounds like a good feature to add.
gnuplot -e "set datafile separator \",\"; set term png; set output 'foo.png'; plot 'foo.csv'"
and if that is the best way then that's one particularly obvious advantage of graph over gnuplot.Personally, I would rather do
<foo.csv tr ',' ' '|gnuplot -e 'set term png;plot "-"'>foo.pngBut I don't really use scripts for other gnuplot terminals, because custom tailoring for individual data set is always required to make any figure presentable. I usually go through ConTeXt to generate PDF file for its TeX features.
You can specify either the column name or number (1 indexed).