Plotting curves from multiple files with gnuplot

前端 未结 1 1307
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 06:28

I want to plot in the same graph a series of data contained in different directories with gnuplot.

I have a collection of folders called Ntimestep=X (whe

相关标签:
1条回答
  • 2020-12-07 07:10

    Gnuplot itself cannot create such file list, but you can call some command line tool or a second script which creates such a list, which can then be used by gnuplot.

    So something like

    list = system('ls Ntimestep=*/occ.dat')
    plot for [file in list] file
    

    On Windows something like list = system('dir /b *.txt') should work, see Script Gnuplot on windows OS (I cannot test it).

    To get the number in the title, using only gnuplot you can use

    t(s) = (s2 = s[11:*], s2[0:strlen(s2)-8])
    plot for [file in list] file title t(file)
    

    To be more flexible regarding the string format you'll again need to use an external tool (e.g. pipe the output of ls through sed).

    0 讨论(0)
提交回复
热议问题