I am using a data-logging system that adds a value to a data file called today.dat every 2 minutes.

Here is what the data looks like:

enter image description here

Here is the gnuplot program I use, where X is time and Y is voltage. It also draws some lines showing constant critical values:

enter image description here

You'll notice that I use the following two commands after the plot command:

pause 30

This makes the plot live and shows me voltage readings on the battery bank for my solar power station as they come in.

The plot works great. It automatically updates so the display is near-real-time.

Here is an example:

enter image description here


Is there a way to have a text box on-screen showing just the latest voltage reading as the chart updates?


This is a very useful answer, taken from @steeldriver's comment above.

Is there a way to put a label for the last entry in gnuplot?


If you are on a unixoid system, you can use tail to extract the last line from the file and plot it separately in whatever way you desire. To give a simple example:

"data.dat" w l,\
"< tail -n 1 data.dat" u 1:2:2 w labels notitle

This will plot the whole of data.dat with lines and the last point with labels, with the label depicting the value.

posted by Wrzlprmft (Tip of the hat to you)

It is not quite what I expected but it definitely does the job. I had to figure out the 1:2:2 thing, and change it to 2:($3):3

It is the same as my plot command but I do a second plot with the third label variable.

Here is a Q&A that sorta explains why:

Labelling individual data points gnuplot

This is a lengthy explanation that basically says it is x:y:l

Explaining x:y:l -- x is the time, and y has ($3) because it is being used as the numeric value. l is just a literal of column 3. Hence 2:($3):3 for my example. notitle is there so it does not show up in the legend.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.