in a script bash, here is what I do:
rtl_power_fftw -f 144100000:146100000 -b 500 -n 100 -g 350 -p 0 -e 1m -q -m plot
Then, I parse the met file and I link the content of the .met file (number of bins, number of scans, etc.) with two variables: nb_bins and nb_scans.
And I create my waterfall as a png image:
gnuplot -persist << EOF
plot 'plot.bin' binary array=${nb_bins}x${nb_scans} format='%float' with image
set term png
set output 'plot.png'
replot
set term wxt
EOF
The problem is that my plot.png image is modified during the first start of my code (bash script.sh), but then, my code is running automatically with crontab * * * * * /my/directory/script.sh and the image is then updated without any content (size of 0 bytes). While my files plot.met and plot.bin are refreshed without any problem.
I tried different things already: using gnuplot -e "" instead of gnuplot persist, without set term wxt, trying different times for crontab, killing the gnuplot process, but nothing worked yet and I don't have any other ideas. Thanks a lot for your help!
Without knowing your detailed arrangement, here is a suggestion for letting gnuplot run in an endless loop (which you can stop by pressing x
). My default terminal is also wxt
.
The example script will plot a function every second with some random factor with a random color just for illustration purpose. Replace it with your plotting command.
I'm not sure if you need a PNG for something else or whether simply displaying the graph in a wxt terminal might be enough.
Actually, I have a simple setup in a lab where a program appends temperature and humidity every minute to a daily file. I run gnuplot completely independently from that and let it display the content of the file every minute.
Not sure if this solves your problem.
Script:
### endless loop for replotting after some waiting time
reset session
stop = 0
bind x "stop=1"
f(x) = sin(x)/x
while (!stop) {
set title strftime("%Y-%m-%d %H:%M:%S",time(0))
b0 = rand(0)+1
plot f(x*b0) w l lw 3 lc rgb 0x1000000*rand(0)
pause 1 # number of seconds
}
### end of script
Result: (screenshot from wxt terminal)
Addition:
If you simply need to create a PNG file from the data which is currently available, create a script file, e.g. plot.gp
set term png
set output 'plot.png'
plot 'plot.bin' binary array=${nb_bins}x${nb_scans} format='%float' with image
set output # can be skipped if gnuplot will be terminated
and call gnuplot from console or bash. I wouldn't use -persist
(which is maybe causing your problems), but then gnuplot will be started and ended again and again.
gnuplot -c "plot.gp"