GNUPLOT:从平滑累积中保存数据 [英] GNUPLOT: saving data from smooth cumulative

查看:86
本文介绍了GNUPLOT:从平滑累积中保存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个均匀的实数均匀随机分布(n = 1000)的简单累积图和直方图:

I make this simple cumulative and histogram plot of a uniform random distribution of real numbers (n=1000):

http://www.filedropper.com/random1_1 :random1.dat

http://www.filedropper.com/random1_1: random1.dat

宏是:

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是:

Now the output.png is:

我如何告诉Gnuplot我不仅要获取累积图,还要获取保存在特定文件中的数字.

How I can tell to Gnuplot I want to take not only the cumulative plot but also the numbers coming from it saved in a particular file.dat ?

推荐答案

您可以在将smoothset table ...一起应用后保存数据.在最简单的情况下,如果只需要累积数据,则使用:

You can save the data after applying smooth with set table .... In the simplest case, if you need only the cumulative data, just use:

set table 'random1-smoothed.dat'
plot 'random1.dat' using (bin($1,width)):(1.0) smooth cumulative
unset table

为了更好地包含在脚本中,您还可以将整个现有的plot命令包装在set table中:

For better inclusion in your script you could also wrap the whole, existing plot command in 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

这篇关于GNUPLOT:从平滑累积中保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆