如何在Gnuplot脚本中选择单词列表而不是数字来计算统计信息
下面的脚本从如何在Gnuplot脚本中选择单词列表而不是数字来计算统计信息,gnuplot,Gnuplot,下面的脚本从.csv文件中获取数据,并在打印之前计算一些统计数据 set encoding iso_8859_1 set key left top font "Helvetica,17" set ylabel "Lookup error probability" font "Helvetica,18" set xlabel "Height [m]" font "Helvetica,18" set xtics font "Helvetica,18" set ytics font "Helveti
.csv
文件中获取数据,并在打印之前计算一些统计数据
set encoding iso_8859_1
set key left top font "Helvetica,17"
set ylabel "Lookup error probability" font "Helvetica,18"
set xlabel "Height [m]" font "Helvetica,18"
set xtics font "Helvetica,18"
set ytics font "Helvetica,18"
set terminal postscript eps enhanced color #size 6.5in,3in
set grid
set key spacing 1.5
set output "ware_f.eps"
list(start,end,increment)=system(sprintf("seq %g %g %g", start, increment, end))
set print "ware0_f.dat"
do for [i in list(4,14,1) ] {
stats "ware0_f.txt" u ($39==i?($54/$55):1/0) name "A" nooutput
print i*1, A_mean, (A_mean - 2.262*A_ssd/sqrt(A_records)),\
(A_mean + 2.262*A_ssd/sqrt(A_records))
}
plot [][] "ware0_f.dat" using 1:2:3:4 with yerrorlines ls 2 lw 3 title "No Int."
数据位于本文档的文件ware0_f.txt
中
计算列$39
的值的统计信息,该列包含数字数据(即4、5、6、…、14)
我想使这个脚本适应列$39
的值,这些值不是数字而是字符串。字符串为“cycles_10”、“cycles_20”、“cycles_80”
上面的链接中还有一个文件cycles_0.txt
,其中列$48
中包含此字符串列表
我想使用与列$48的周期相同的值的均值和偏差来计算置信区间的统计数据。您可以尝试:
# Your strings list
ListOfString = "cycle_10 cycle_20 cycle_30 cycle_40 cycle_50 cycle_60 cycle_70 cycle_80"
# Creates a datafile
set print "Data.dat"
# Loop through your list
do for [i in ListOfString]{
# Performs stats
stats "cycles_0.txt" u (stringcolumn(48) eq i ? ($54/$55) : 1/0 ) name "A" nooutput
# Logical test
if (exists("A_mean")){
# Writes a formatted string on 'Data.dat'
print sprintf('%s %f %f %f',\
i,\
A_mean,\
(A_mean - 2.262*A_ssd/sqrt(A_records)),\
(A_mean + 2.262*A_ssd/sqrt(A_records)))
}
}
# Close 'Data.dat'
unset print
# Turn-off the enhanced mode on terminal
set termoption noenhanced
# put white spaces on both sides of graph
set offset 1,1
# The plot using $0 as 'x' and $1 as xlabels
plot "Data.dat" using 0:2:3:4:xticlabels(1) with yerrorlines
文件Data.dat
包含:
cycle_10 1.486349 1.096812 1.875886
cycle_20 1.535556 1.171189 1.899922
cycle_30 0.894661 0.636397 1.152925
cycle_40 0.578156 0.396785 0.759527
cycle_50 0.246576 0.191916 0.301236
结果是:
please@Thor谢谢你的评论。我简化了脚本并添加了数据文件。一个是我在本例中使用的数据文件,另一个是我希望用于选择数据并计算平均值和偏差的值的文件。感谢您的解决方案。我可以问你怎么写x标签上的数字吗,例如10,20,30,40,。。。而不是周期10,周期20等等?。