Peter S
Peter S

Reputation: 575

Set columnhead as Title in Gnuplot

I'm logging data and I want to periodically send plots of the logged data (temperature and humidity) via mail. The plot should cover the data from last week. What I would like to do is automatically generate a Plot Title that includes the Dates shown in the Plot. So a simple title like:

Week 01.01.2016 - 08.01.2016 would be great.

I am thinking about creating a .csv file with the data like this

2016-01-01 00:01      20.0           40.0
2016-01-01 00:02      20.0           40.0

but add the First and the Last Date at the beginning of the file in the first row so that the .csv file reads like this:

2016-01-01 - 2016-01-08
2016-01-01 00:01      20.0           40.0
2016-01-01 00:02      20.0           40.0

Can I tell gnuplot to simply take the first Line as Plot Titel? something as simple as set title columnhead would be great

Upvotes: 0

Views: 559

Answers (1)

ewcz
ewcz

Reputation: 13087

assuming that the first line of your data file contains the title, one could proceed as:

set title "`head -n1 test.dat`"
plot "<tail -n+2 test.dat" u 1:2 w lp, '' u 1:3 w lp

Here, the first command extracts the first line and uses it as the title, while the second command plots the remaining lines from the input file...

Upvotes: 1

Related Questions