Dark Knight Rising
Dark Knight Rising

Reputation: 51

Gnuplot set title dynamically

I am trying to set the title of my gnuplot chart from the last line in my .dat file but I am not sure what to do.

My .dat file reads like:

Column1 Column2
1 0.5
2 1.5
3 2.5
4 3.5
5 4.5
6 5.5   
Average is ??????

Would anyone know the command to set the title using the text of the last line?

Upvotes: 1

Views: 947

Answers (1)

mgilson
mgilson

Reputation: 309929

gnuplot allows for shell-style backtick expansion. Combining that with the unix utility tail should work just fine:

set title "`tail -1 myfile.dat`"
plot 'myfile.dat' u 1:2

Upvotes: 2

Related Questions