سؤال

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?

هل كانت مفيدة؟

المحلول

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top