How to run a shell command in Gnuplot and place th

2019-07-11 07:20发布

I have the following Gnuplot:

set encoding iso_8859_1
set key right bottom #font "Helvetica,17" 
set ylabel "Lookup error probability" font "Helvetica,17"
set xlabel "Hight of the reader (m)" font "Helvetica,17"
set xtics font "Helvetica,15"
set ytics font "Helvetica,15"
set size 0.75, 1.05
set terminal postscript eps enhanced color #"Helvetica" 16 #size 3.5in,3in
set grid 
set key spacing 1.5

set output "ProbError6x6.eps"
list(start,end,increment)=system(sprintf("seq %g %g %g", start, increment, end))

system("(awk '(NR>8 ){print; }' Hight_6x6.csv | sed -e 's/[",]/ /g' | sort -nk36) > pe_H_6x6.txt")

set print "pe_H_6x6.dat"
do for [i in list(2,3.5,0.25) ] {
  stats "pe_H_6x6.txt" u ($36==i?($37/$38):1/0) name "A" nooutput
  print i*1, A_mean,   (A_mean - 1.833*A_ssd/sqrt(A_records)),\
    (A_mean + 1.833*A_ssd/sqrt(A_records))
}
plot [][] "pe_H_6x6.dat" using 1:2:3:4 with yerrorlines ls 2 title "6x6 blocks"

The line with the system and with the awk code does not work in my Gnuplot script. However, it works in the unix shell. This code removes commas and , in Hight_6x6.csv, skips the first 8 lines and sort the result by the values of the 36th column. I cannot make it work in the Gnuplot script. The CSV file is in this link.

标签: gnuplot
1条回答
2楼-- · 2019-07-11 08:20

Your issue is probably that you include a double quote inside the command:

system("(awk '(NR>8 ){print; }' Hight_6x6.csv | sed -e 's/[",]/ /g' | sort -nk36) > pe_H_6x6.txt"
                                                           ^

One work-around is to use backquotes, e.g.:

`(awk '(NR>8 ){print; }' Hight_6x6.csv | sed -e 's/[",]/ /g' | sort -nk36 > pe_H_6x6.txt`

Or as I would have written it:

`tail -n+8 Hight_6x6.csv | tr '",' ' ' | sort -nk36 > pe_H_6x6.txt`
查看更多
登录 后发表回答