Search code examples
gnuplotfence-plots

Gnuplot: How to "stretch" multiple files along the 3rd dimension in splot?


I want to compare nine data sets in gnuplot using splots. Each of the files is in a subdirectory and corresponds to a different parameter. I have a list of file names, so something like plot for [file in list] file u 1:5 works well. However, I want to be able to make a fence plot out of that by somehow strechting these files out along a third axis in splot.

How do I do something like splot for [file in list] file u 1:5:<LIST OF VALUES>, where the <LIST OF VALUES> is the list of parameters that doesn't appear in the data files themselves, but has to be put in by hand? The explicit list is {0.25,0.5,1,5,10,15,20,25,30}


Solution

  • As a workaround, you could loop over an integer index and extract the corresponding file name and z-index from a string variable:

    #as a minimal example, plot the value of the "z-index"
    #and use the file name as key label
    
    fileList="file1.dat file2.dat"
    valsList="0.1 0.2"
    
    plot for [i=1:words(fileList)] real(word(valsList, i)) t word(fileList, i)
    

    In newer versions of Gnuplot, this can be simplified with arrays.