2

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.

user1993416
  • 698
  • 1
  • 9
  • 28

1 Answers1

2

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`
Thor
  • 45,082
  • 11
  • 119
  • 130
  • thank you very much. I would take the last solution. I did not know `tr` translation command. Do you know any way to insert the output of CSV processing commands in the `stat` Gnuplot command?. I would like not to use intermediate files when possible. – user1993416 Nov 28 '18 at 15:18
  • @user1993416: you might be able to use the popen notation, e.g. `stat “< your_command”`. You can read more about it online or in `help plot special-filenames` – Thor Nov 29 '18 at 09:40
  • thank you. I have modified the line to merge two csv files from row 8 but it does not work. I am going to add a new question for this. – user1993416 Nov 29 '18 at 17:23
  • the new question is in https://stackoverflow.com/questions/53544733/merge-two-csv-files-in-a-gnuplot-script – user1993416 Nov 29 '18 at 17:41