0
votes

The aim is to recrate the plot given in the 'gnuplot demo pages' : make it read data from a data file: txt/csv/dat when the data/file is updated; the plot updates accordingly.. ie data is added to data file evey 10mins additional how can processed in a way that only the most recent update in the data file is plotted not the entire feed of data?

.. so is there another way?

My attempts of creating what I thought would be straight forward..hit the wall; all input will be welcome. I try adding: plot [0:100] '< head -1 file.dat' using 1:6 with points

***this doesn't output data using the given format.

Above that line of code I then include/ tried:

f(x) = (x == stats_max ? 1:0)
as above....plot "mydatafile.somformat'
pause 3 reread

the message returned was stats cannot be used with polar data

original code given below:

set zzeroaxis; set xzeroaxis; set yzeroaxis
set xyplane at 0
unset border
unset key
unset xtics
unset ytics
set ztics axis

set arrow 1 from 0,0,0 to 1,0,0 head filled lw 1.5
set label 1 at 1.2,0,0 "X" center
set arrow 2 from 0,0,0 to 0,1,0 head filled lw 1.5
set label 2 at 0,1.2,0 "Y" center
set arrow 3 from 0,0,0 to 0,0,21 head filled lw 1.5
set label 3 at 0,0,23 "Z" center

set view 60, 30, 1., 1.75

set multiplot layout 1,3

set view azimuth 0.
set title 'azimuth 0' offset 0,2
splot sample [t=0:20] '+' using (cos($1)):(sin($1)):($1) with lines lw 2

set title 'azimuth 10' offset 0,2
set view azimuth 10.
replot

set title 'azimuth 60' offset 0,2
set view azimuth 60.
replot

unset multiplot```
1
I do not understand what you mean by "only the most recent feed of data is plotted". Is it that you want to keep the previous plot because that data is no longer available in the file, but add new data on top of it? If the previous data is still in the file, what is the problem with simply re-running your script every ten minutes? - Ethan
if this represented my data set: # x y 6.02 153.33 9.59 154.03 9.59 154.03 new data>>10.58 153.22<< if new data is appended to bottom; it reads and plots only the last entry(ie the newly appended data). Do you know how this might be achieved. also show if new data appends from the top instead of the bottom; it better to measure twice so you can cut once. - Randolp

1 Answers

0
votes

So each plot will only contain a single point?

Read and plot only the last entry in the file:

plot '< tail -1 file.dat' with points

Read and plot only the first entry in the file:

plot '< head -1 file.dat' with points

Be aware that this can only work if the program writing to the data file closes it after each write. If it holds the file open all the time then gnuplot will probably not be able to see any new data.

Edit:

3D example reading data from a file:

set view equal xy
set zzeroaxis; set xzeroaxis; set yzeroaxis
set xyplane at 0
unset border
unset key
unset xtics
unset ytics
set ztics axis

set arrow 1 from 0,0,0 to graph 1,0,0 head filled lw 1.5
set label 1 at graph 1.1,0,0 "X" center
set arrow 2 from 0,0,0 to graph 0,1,0 head filled lw 1.5
set label 2 at graph 0,1.1,0 "Y" center
set arrow 3 from 0,0,0 to graph 0,0,1 head filled lw 1.5
set label 3 at graph 0,0,1.1 "Z" center

set view 60, 30, 1., 1.75

set multiplot layout 1,3

set view azimuth 0.
set title 'azimuth 0' offset 0,2
splot 'silver.dat' using 1:2:3 with lines lw 2

set title 'azimuth 10' offset 0,2
set view azimuth 10.
replot

set title 'azimuth 60' offset 0,2
set view azimuth 60.
replot

unset multiplot

enter image description here