plot - GNUPLOT:从平滑累积中保存数据

标签 plot statistics gnuplot cumulative-sum

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

http://www.filedropper.com/random1_1 : 随机1.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 是:

enter image description here

我如何告诉 Gnuplot 我不仅要获取累积图,还要获取保存在特定 file.dat 中的来自它的数字?

最佳答案

您可以在使用set table ... 应用smooth 后保存数据。在最简单的情况下,如果您只需要累积数据,只需使用:

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

关于plot - GNUPLOT:从平滑累积中保存数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24105943/

相关文章:

r - 如何检索绘图设备窗口的标题?

r - 如何呈现包含时变协变量的生存数据并在 R 中拟合模型

Gnuplot:使用调色板时数据点的透明度

graph - 如何在图形上绘制连接的网络节点?

r - 将多项研究的研究平均值绘制为散点图,点大小与研究样本大小相对应

Python-绘图不可用

r - 在 R 中创建具有定义相关性的正态分布变量

GNUplot - 绘图数据文件(简单的 X 和 Y 列) - 在图形上设置合适的颜色和比例

logging - 更改 Bokeh 服务的日志记录级别

c++ - 如何计算OpenCV中两个GMM之间的距离?