Friday 11 May 2012

GNUplot Snippets

I like to use a lot of GNUplot to make graphs from the command line and more specifically scripts...for example, the script below reads from a csv and emits them in a scatter plot. Pretty straightforward but nicely extensible. If you leave things out (eg. xrange) GNUplot will just decide them for you based on the data set!

Do definitely try GNUplot, I've never looked back! No more point and click excel nightmares.

#!/bin/bash

# Some code here that generates some pretty csv

/usr/bin/gnuplot  <<\EOF 
reset  
set term png size 500, 270
set key top left
set output "graph.png"
set datafile separator ","
set xrange [0:24000]
set xlabel "Integers"
set ylabel "Time (s)"
plot "test.csv" using 1:2 title "Mapped", "test.csv" using 1:3 title "Unmapped"
EOF 
 
Generates the following plot...(obviously depends on your data!)

No comments:

Post a Comment

Leave a comment!

Can we just autofill city and state? Please!

Coming from a country that is not the US where zip/postal codes are hyper specific, it always drives me nuts when you are filling in a form ...