To run a gnuplot script non-interactively (possibly passing positional arguments from the command line) use the -c flag of gnuplot. For example:
gnuplot -c plot-something.gnuplot "Measurements on A" measurements.csv
Inside plot-something.gnuplot script, we can refer to command-line arguments as:
TITLE = ARG1
DATAFILE = ARG2
...As in previous example, but now datafile has the special name <cat. Note that not reading from a regular file, has the limitation that we cannot have multiple plots (as data is read once from pipe).
For example:
cat measurements.csv | gnuplot -c plot-something.gnuplot "Measurements on A"
Inside plot-something.gnuplot we use something like:
...
TITLE = ARG1
plot '<cat' using ($1):($2) with lines title TITLEAssume the following defaults:
DATAFILE="1.csv"
set grid
set datafile separator ";"
set terminal png font "sans-serif,10"
set output "1.png"Plot a simple line:
plot DATAFILE using 1:2 with lines title "Something"Plot a line with filled area:
set style fill transparent solid 0.33
plot DATAFILE using 1:2 with filledcurves x1 title "Another thing"To plot time series, we must give read format (to read the input timestamp) and a write format for labels placed along x tics:
# the X axis contains time data
set xdata time
# the format to read x datapoints from input
# see http://gnuplot.sourceforge.net/docs_4.2/node274.html
set timefmt "%s"
# the format to write datapoints at x axis
# see http://gnuplot.sourceforge.net/docs_4.2/node185.html
set xdata time
set format x "%b %d\n%H:%M"
# place a X tick every 2h
set xtic 7200
plot DATAFILE using 1:2 with lines title "Series #1", using 1:3 with lines title "Series #2"