0
votes

I have a data file with schema as "object parameter output1 output2 ...... outputk". For eg.

A 0.1 0.2 0.43 0.81 0.60
A 0.2 0.1 0.42 0.83 0.62
A 0.3 0.5 0.48 0.84 0.65
B 0.1 0.1 0.42 0.83 0.62
B 0.2 0.1 0.82 0.93 0.61
B 0.3 0.5 0.48 0.34 0.15
...

I want to create multiple plots, each plot corresponding to an object, with x axis being the parameter and series being the outputs. Currently, I've written a python script which dumps the rows for each object in different files and then calls gnuplot. Is there a more elegant way to plot it?

1
Do you want to plot all columns for a certain object? One line for each combination of output1 vs parameter, output2 vs parameter, ... outputk vs parameter? Do you known the number of columns, or should that be determined automatically? In any case you could do the processing on the fly instead of saving it to temporary files: plot '< python myscript.py', or plot '< python mybetterscript.py --obj A'. - Christoph

1 Answers

0
votes

You are looking for this:

plot 'data.txt' using (strcol(1) eq "A" ? $2 : 1/0):4 with line

which results to: enter image description here

If you would like to create plots for every object use:

do for [object in "A B"] {
  reset
  set title sprintf("Object %s",object)
  plot 'data.txt' using (strcol(1) eq object ? $2 : 1/0):4 notitle with line
  pause -1
}

Just press Enter for next plot. Of course you can export these plots in files, too.