Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

(Currently using gnuplot version 4.6.3)

I am plotting from several datafiles (dataA, dataB, dataC, etc..) where the data is broken up into datablocks (with single lines separating them) and prepended by some text:

testing A001
#A       B       C
-100    -91     -90
-95     -88     -88
-90     -84     -83
-85     -79     -79 

testing A002
#A       B       C
-100    -91     -90
-95     -88     -88
-90     -84     -83
-85     -79     -79 

... etc. 

Edit: I apologize if my explanation below is a little confusing - I essentially want to do what this guy also wants to do: http://gnuplot.10905.n7.nabble.com/Using-title-columnheader-td3900.html (However the solution posted in response did not work for me and I also don't quite understand it)

I am currently using "do" iterations to plot each datablock of all datafiles simultaneously on a single graph. However, I'm having trouble with the "set autotitle" command - it only takes, in this example, "A001", "B001",etc. and uses it as the title of every single graph so that plots of subsequent datablocks are also labelled "A001", "B001", etc. whereas I would like to have the graphs labelled "A001", "A002", .. "B001", "B002", etc.

This is my current plot command:

do for [i=0:25] {
plotfile = "RESULT".i.".png"
set output plotfile
set key autotitle columnhead
plot "dataA.dat" every ::0:i:4:i using 1:2 with lines title columnhead(2), plot "dataB.dat" every ::0:i:4:i using ... etc.
}

Any help/hints are appreciated!!

share|improve this question

1 Answer

up vote 0 down vote accepted

An example from the link you give works this way. You need two empty lines between blocks.

i=1
plot "-" using 1:2:-2 index i title columnheader
testing A001
#A       B       C
-100    -91     -90
-95     -88     -88
-90     -84     -83
-85     -79     -79 


testing A002
#A       B       C
-100    -91     -90
-95     -88     -88
-90     -84     -83
-85     -79     -79
EOF
share|improve this answer
 
I've tried replacing all newlines with double newlines but I'm getting an error. I suspect it's because I'm also using the "every" command which relies on datablocks to be separated by single lines. Has anybody ever tried to combine that command with the "every" command? –  Mirnoc Jun 28 at 15:48
 
*** Tried taking out the "every" command and turns out it was redundant in this case. Huh. I guess I got lucky.. thanks for your help! –  Mirnoc Jun 28 at 16:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.