Loop structure inside gnuplot?

前端 未结 6 1000
孤城傲影
孤城傲影 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:01

    There sure is (in gnuplot 4.4+):

    plot for [i=1:1000] 'data'.i.'.txt' using 1:2 title 'Flow '.i
    

    The variable i can be interpreted as a variable or a string, so you could do something like

    plot for [i=1:1000] 'data'.i.'.txt' using 1:($2+i) title 'Flow '.i
    

    if you want to have lines offset from each other.

    Type help iteration at the gnuplot command line for more info.

    Also be sure to see @DarioP's answer about the do for syntax; that gives you something closer to a traditional for loop.

提交回复
热议问题