Loop structure inside gnuplot?

前端 未结 6 1004
孤城傲影
孤城傲影 2020-11-27 10:40

Is there any way to iteratively retrieve data from multiple files and plot them on the same graph in gnuplot. Suppose I have files like data1.txt, data2.txt......data1000.tx

6条回答
  •  青春惊慌失措
    2020-11-27 11:00

    I have the script all.p

    set ...
    ...
    list=system('ls -1B *.dat')
    plot for [file in list] file w l u 1:2 t file
    

    Here the two last rows are literal, not heuristic. Then i run

    $ gnuplot -p all.p
    

    Change *.dat to the file type you have, or add file types.

    Next step: Add to ~/.bashrc this line

    alias p='gnuplot -p ~/./all.p'
    

    and put your file all.p int your home directory and voila. You can plot all files in any directory by typing p and enter.

    EDIT I changed the command, because it didn't work. Previously it contained list(i)=word(system(ls -1B *.dat),i).

提交回复
热议问题