【Record】gnuplot|How does gnuplot draw multiple pictures into one?

Version: gnuplot 5.2 patchlevel 2

After solving it countless times, I still forget repeatedly, get angry, and remember.

The function of the following program:
read all dat files in the folder, and draw all dat results in a picture and mark the legend:

set term png
set output "output.png"
set xdata time
set timefmt "%d/%H:%M"
set format x "%d/%H:%M"
set xlabel "Time"
set ylabel "BBs"
set title "f103/Drone"
set xtics 14400
set key right bottom

# Find .dat files in the current directory
file_list = system("find . -maxdepth 1 -name '*.dat' -printf '%f\n'")

# Loop through the files and add plot commands
plot for [dataset in file_list] dataset using 1:2 with lines title dataset

# another way:
# plot word(file_list, 1) using 1:2 with lines title "TEST1", \
#      word(file_list, 2) using 1:2 with lines title "TEST2", \
#      word(file_list, 3) using 1:2 with lines title "TEST3", \
#      word(file_list, 4) using 1:2 with lines title "TEST4", \
#      word(file_list, 5) using 1:2 with lines title "TEST5", \

Reference: for loops in plot command, for loop in plot command

result:
insert image description here

Guess you like

Origin blog.csdn.net/qq_46106285/article/details/131623714