Table of Contents
Gnuplot is a feature rich command-line graphing utility available for Windows, Linux and Mac OSX. Though capable of generating much more advanced formula-based plots its also very handy at producing quick, ad-hoc time series graphs.
The Test Dataset
For our example we'll use the following basic dataset saved to file 'mydata.txt'
2019-02-01 15 2019-03-01 8 2019-04-01 16 2019-05-01 20 2019-06-01 14
These commands were tested with gnuplot 5.0 patchlevel 5
set xdata time # Indicate that x-axis values are time values set timefmt "%Y-%m-%d" # Indicate the pattern the time values will be in set format x "%m/%y" # Set how the dates will be displayed on the plot set xrange ["2019-01-01":"2019-12-31"] # Set x-axis range of values set yrange [0:30] # Set y-axis range of values set key off # Turn off graph legend set xtics rotate by -45 # Rotate dates on x-axis 45deg for cleaner display set title 'Squirrels Spotted' # Set graph title set terminal jpeg # Set the output format to jpeg set output 'output.jpg' # Set output file to output.jpg plot 'mydata.txt' using 1:2 with linespoints linetype 6 linewidth 2
Although you can paste the commands above right into gnuplot, it usually makes sense to put these commands in their own file for future reuse and reference. If we put these into the file 'gpcommands.txt' then we just need to run:
$ gnuplot < gpcommands.txt
To have it generate the following plot:
Although there are other graphing libraries and software that may plot time series graphs in a more visually appealing way there are few-to-none that match gnuplot's efficiency. More often than not you'll just need something that will visualize a set of data points thats 'good enough' and for this reason gnuplot is a very effective tool to keep in mind.