2

I want to add the last value of a series to the plots legend. I tried different variants of this SO answer like so:

plot filename using 1:2:(last=$2) title sprintf("1/N %0.2f", last) with lines

But this puts nan into the label. And if I do 1:(last=$2) this messes up the whole line.

The problem is I need to make it platform independent meaning it needs to run on windows and linux. So I can not just tail and awk. Is there a build in way to achieve this?

KIC
  • 5,887
  • 7
  • 58
  • 98

1 Answers1

1

You cannot use anything from the using statement in the plot's title. You can process your data first with stats and using (last=$2) and use that result in the plot:

stats filename using (last=$2) nooutput
plot filename using 1:2 title sprintf("1/N %0.2f", last) with lines
Christoph
  • 47,569
  • 8
  • 87
  • 187