2
votes

I'm looking for a way to plot data from different files into one graph.

I'm testing different approaches to a problem. I have some parameters and I'm trying to conclude how the results are related to these parameters. I run some tests on the different solutions I'm comparing, and I redo this several times with different parameters.

So I have several .csv files looking like this.

       test1    test2    test3    test4   ...
sol1     1        1        1        1 
sol2     1        1        1        1 
sol3     1        1        1        1 
sol4     1        1        1        1 
...

(These are of course filled with real data and not just 1's)

I want to plot a graph where the Y axis is the result of (for example) test1/sol1 and the x axis plots the different parameter values (the different .csv files).

I hope I have made clear what i'm trying to create.

I am hoping there is a way of doing this directly in gnuplot. The file structure is this way in order to create some other graphs, so I don't really want to change it.

I read about the possibility of concatenating two files, but i don't really see that of being much use here.

EDIT: (thanks to Christoph) I want to plot the value in the cell test1/sol1 vs my parameter. The parameter is changing per file. So I need to read 1 datapoint per file.

In the end I would like to plot this information for different solutions in one graph. So for the cells test1/sol1, test1/sol2, test1/sol3,...

In the example below, the x axis would be the changing parameter, the Y axis would be the value in the corresponding cell from column 'test1' and the different lines correspond to the different solutions.

graph example
(source: googlecode.com)

(random image from google)

I hope it's clearer now what I'm trying to achieve.

1
I don't understand what you want to plot: What is test1/sol1 supposed to be on the y-axis? Do you want to plot the value in the cell test1/sol1 vs. the respective parameter (contained in the filename?)? You could do that with iterations like plot for [file in filelist], but that won't work with lines, only with boxes, or points etc. Also, possible solutions depend on other values, which you want to include in the plot: should sol1 appear somewhere or test1? What about the parameter value etc.Christoph
Hi Christoph. Thanks for your reply. I indeed want to plot the value in the cell test1/sol1 vs the parameter. The parameter is simply 1,2,3,4... (and is contained in the filename). The values in the cells are percentages, but that shouldn't really matter. I want to use lines because I want to put multiple plots (test1/sol2, test1/sol3,...) on the same graph to compare them.user3319803
Ok, because you cannot connect points stemming from different files with lines. That one of the main points why one needs to concatenate several files. Or you plot inside set table and then replot it.Christoph

1 Answers

1
votes

Probably not the best solution, as I'm not yet very experienced with Gnuplot, but I managed to do it like this:

sol1 = "< (cat param0.csv param1.csv param2.csv | grep sol1)"
plot sol1 using 2 with lines title "sol1"

So cat this will put the files with different parameter after each other, and then I only keep the lines with sol1 in them. Then I just plot the first column (values for test1)

I just repeat this for the different solutions, with copy paste (since the number of solutions is fixed, this appeared to be the easiest way).