2
votes

I would like to do a splot using instead of a traditional 3 columns data file, a one column data file and the others two columns defined inside gnuplot. I have:

array r1[22554]
array r2[22554]
k=0
do for [j=1:179] {
  do for [i=1:126] {
    k=k+1
    r1[k]=i
    r2[k]=j
  }
}
do for [i=1:10000:10] {
  j=i/10
  outfile = sprintf('pop%06.0f.png',j)
  set output outfile
  splot "file.txt" index i u r1:r2:1 w l palette 
}

But this last line doesn't work. How can I specify the I want to make the plot using X and Y from my vectors and Z from the file?

Thank you very much in advance

Cayo Gonçalves

1
how does your file.txt look like? 1000 lines or 10000 lines? With or without double empty lines? Please describe the strucure of your file.txt or give a few example lines. Which line of your file should go together with which x and y value? - theozh
This file has 10000 sets of 22554 lines with 1 column. Each set is separated by double empty lines. I want to create a png file for each set (index). My X is r1, Y is r2 and Z is the 22554 lines I take from the file. This group of r1:r2:(first colunm of file) defines my meshgrid for each index. - Cayo Emilio

1 Answers

1
votes

Ok, I see, I was missing the information of 10000 sets with 22554 lines each. Since I do not have the file, I cannot test it, but:

splot "file.txt" index i u (r1[$0+1]):(r2[$0+1]):1 w l palette

should do what you need. $0 is a pseudo-column and returns the line number (starting from 0) of a (sub-)block (addressed by index). And with this number you index your array (starting from 1). Check also help pseudocolumns.

Addition:

Actually, you don't need to create arrays beforehand. You can simply use formulae to get your X and Y values from the line number ($0). Keep in mind, that in gnuplot / will be integer division if both numbers are integer. Nevertheless, I am using int(n/RowCount).

SetCount = 10000
RowCount = 179
ColCount = 126
XValue(n) = int(n)%ColCount
YValue(n) = int(n/RowCount)

do for [i=1:SetCount:10] {
    j=i/10
    outfile = sprintf('pop%06.0f.png',j)
    set output outfile
    splot "file.txt" index i u (XValue($0)):(YValue($0)):1 w l palette
}