我绘制了实数均匀随机分布 (n=1000) 的简单累积和直方图:
http://www.filedropper.com/random1_1 http://www.filedropper.com/random1_1:随机1天
宏是:
unset key
clear
reset
n=120 #number of intervals
max=4. #max value
min=1. #min value
width=(max-min)/n #interval width
#function used to map a value to the intervals
bin(x,width)=width*floor(x/width)+width/2.0 # cosi viene centrato in mezzo
set xtics min,(max-min)/10,max
set boxwidth width
set style fill solid 0.5 border
set ylabel 'Frequency'
set y2label 'Cumulative frequency'
set y2tics 0,100,1000
set ytics nomirror
set xrange [0.9:4.1]
set yrange [0:25]
set terminal pngcairo size 800,500 enhanced font 'Verdana,14'
set output "testCum.png"
plot 'random1.dat' using (bin($1,width)):(1.0) smooth frequency with boxes title 'histogram',\
'' using (bin($1,width)):(1.0) smooth cumulative axis x1y2 w l lt 2 lw 2 lc rgb 'green' title 'cumul'
现在output.png是:
我如何告诉 Gnuplot 我不仅想获取累积图,还想获取保存在特定 file.dat 中的数字?
申请后可以保存数据smooth
with set table ...
。在最简单的情况下,如果您只需要累积数据,只需使用:
set table 'random1-smoothed.dat'
plot 'random1.dat' using (bin($1,width)):(1.0) smooth cumulative
unset table
为了更好地包含在您的脚本中,您还可以包装整个现有的plot
命令输入set table
:
...
set table 'random1-smoothed.dat'
plot 'random1.dat' using (bin($1,width)):(1.0) smooth frequency with boxes title 'histogram',\
'' using (bin($1,width)):(1.0) smooth cumulative axis x1y2 w l lt 2 lw 2 lc rgb 'green' title 'cumul'
unset table
set terminal pngcairo size 800,500 enhanced font 'Verdana,14'
set output "testCum.png"
replot
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)