Menu

#195 plot multiple kurtosis stats in one plot using "plot for"

None
open-not-a-bug
nobody
None
2016-01-11
2016-01-07
Anonymous
No

gnuplot 5.0

I would like to be able to plot multiple kurtosis stats in one plot using the gnuplot for loop. I am using gnuplot 5.0.

I am able to iterate and calculate multiple kurtosis values from different ranges of the same data, but I am having trouble plotting the all the A#_kurtosis values in one figure using the gnuplot loop. Below is the code snippet I am using.

It appears that the iteration on “plottest(I)” in the plot loop is not working. I have tried different approaches to plot with no luck.

Code snippet:
do for [i=10000:overlap:1000] {
range1=i
range2=i+20000
stats 'press_100hz_TS.csv' every ::range1::range2 u (column(col1)) name "A".i.""
}

plottest(n)=gprintf("A%d_kurtosis",n)
plot for [i=10000:overlap:1000] "+" u (1+i/100):plottest(i) with points ls 2

Error that prints to screen:
line 0: warning: no column with header "A10000_kurtosis"
line 0: warning: no column with header "A11000_kurtosis"
line 0: warning: no column with header "A12000_kurtosis"
line 0: warning: no column with header "A13000_kurtosis"
line 0: warning: no column with header "A14000_kurtosis"

Different approaches tested:
plot for [i=10000:overlap:1000] "+" u (1+i/100):(plottest[i]) with points ls 2
plot for [i=10000:overlap:1000] "+" u (1+i/100):(A%d_kurtosis,i) with points ls 2
plot for [i=10000:overlap:1000] "+" u (1+i/100):("A%d_kurtosis",i) with points ls 2
plot for [i=10000:overlap:1000] "+" u (1+i/100):(sprintf("A%d_kurtosis",i)) with points ls 2
plot for [i=10000:overlap:1000] "+" u (1+i/100):(gprintf("A%d_kurtosis",i)) with points ls 2
plot for [i=10000:overlap:1000] "+" u (1+i/100):(A"".[i].""_kurtosis) with points ls 2**

Thanks.

Discussion

  • Bastian Märkisch

    You are looking for the value function to access a variable's content.

     
  • Bastian Märkisch

    • status: open --> open-not-a-bug
    • Group: -->
    • Priority: -->
     
  • Karl Ratzsch

    Karl Ratzsch - 2016-01-07

    (This is not a bug at all, should be moved to "Support Requests")

    You've mixed up variable names and column header names, plus you've misunderstood the "for" loop in the plot command.

    Your function plottest(n) should return the kurtosis, i.e. the value, stored in the variable Axxxx_kurtosis. Right?

    So

    plottest(n) = value(gprintf("A%d_kurtosis",n))
    

    , and your plot command should then read

    set xrange ...
    plot plottest(x)
    

    Your method is still quite unorthodox. You'd better (if you don't use an external program like octave for the evaluation (recommended)) write the kurtosis values into a data file that you can then plot, without creating thousands of variables.

    set print $kdata # check "help inline data"
    do for [i=10000:overlap:1000] {
    range1=i
    range2=i+20000
    stats 'press_100hz_TS.csv' every ::range1::range2 u 1
    print gprintf("%f %f",i,STATS_kurtosis)
    }
    set print
    
    plot $kdata
    
     
  • Ethan Merritt

    Ethan Merritt - 2016-01-11

    Ticket moved from /p/gnuplot/bugs/1729/

    Can't be converted:

    • _milestone:
    • _priority:
     

Log in to post a comment.