Plot all files in a directory simultanously with gnuplot?

前端 未结 4 2131
梦如初夏
梦如初夏 2020-12-17 19:34

I want to do something similar to this question: gnuplot : plotting data from multiple input files in a single graph.

I want to plot simultaneously all the

4条回答
  •  甜味超标
    2020-12-17 20:01

    As an alternative to Jonatan's answer, I would go with

    FILES = system("ls -1 *.dat")
    plot for [data in FILES] data u 1:2 w p pt 1 lt rgb 'black' notitle
    

    or

    plot '<(cat *.dat)' u 3:2 title 'your data'
    

    The first option gives you more flexibility if you want to label each curve. For example, if you have several files with names data_1.dat, data_2.dat, etc., which will be labeled as 1, 2, etc., then:

    FILES = system("ls -1 data_*.dat")
    LABEL = system("ls -1 data_*.dat | sed -e 's/data_//' -e 's/.dat//'")
    
    plot for [i=1:words(FILES)] word(FILES,i) u 3:2 title word(LABEL,i) noenhanced
    

提交回复
热议问题