-1

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 (where X can be for example 100, 200, 400 and so on). Inside each of this folder I have a file occ.dat which contains the data I want to plot, let's say 3 columns (first x points, second and third y points). I want my gnuplot script to automatically detect all the folders by the name Ntimestep=X and add the data contained in the file Ntimestep=X/occ.dat in my plot.

I want also the number X to appear in the legend of the plot.

Example directory structure:

- Ntimestep=100
  ~ occ.dat
  ~ <other files>
- Ntimestep=200
  ~ occ.dat
  ~ <other files>
amzon-ex
  • 1,645
  • 1
  • 6
  • 28
user3368447
  • 125
  • 3
  • 10
  • Your question is quite unclear. Please give a couple of example folder names and filenames, and an example of your data and of your plotting commands. – Mark Setchell Oct 31 '14 at 15:57

1 Answers1

3

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).

Community
  • 1
  • 1
Christoph
  • 47,569
  • 8
  • 87
  • 187