Gnuplot plotting data from a file up to some row

后端 未结 5 1538
逝去的感伤
逝去的感伤 2020-11-30 22:44

I have data in some text file which has let\'s say 10000 rows and 2 columns. I know that I can plot it easily by plot \"filename.txt\" using 1:2 with lines . Wh

5条回答
  •  自闭症患者
    2020-11-30 23:25

    You can probably cut out the reliance on an external utility (If your system doesn't have them installed for example) using the pseudo-column 0.

    see help plot datafile using pseudocolumn

    Try something like:

    LINEMIN=1000
    LINEMAX=2000
    
    #create a function that accepts linenumber as first arg
    #an returns second arg if linenumber in the given range.
    InRange(x,y)=((x>=LINEMIN) ? ((x<=LINEMAX) ? y:1/0) : 1/0)
    
    plot "filename.txt" using (InRange($0,$1)):2 with lines
    

    (tested on Gnuplot 4.4.2, Linux)

提交回复
热议问题