有人知道在直方图的不同区域上叠加高斯曲线吗?我的目的是突出数据的趋势。谢谢。卢西奥
我的数据(以%为单位并保存在hist.dat中)是:
EXP 0-10k 10-25k 25-50k 50-100k 100k
A 51.7 45 3 0.2 0.1
B 2.89 17.1 32 27 21
C 1.35 5.15 7.1 11.4 75
以及绘制它的命令是:
set boxwidth 0.75 absolute
set style fill solid 1.00 border -1
set style data histogram
set style histogram cluster gap 1
set ylabel "Count of structures (%)"
set xlabel "Experimental methods"
plot 'hist.dat' using 2:xtic(1) title col, \
'' using 3:xtic(1) title col, \
'' using 4:xtic(1) title col, \
'' using 5:xtic(1) title col, \
'' using 6:xtic(1) title col
最佳答案
您可以定义钟形曲线的函数:
f(x) = (1 / s * sqrt(2 * pi)) * exp(- ((x - m) / s)**2 / 2)
然后使用 fit
命令将其适合您的数据点:
fit f(x) 'hist.dat' using 3:1 via m, s
我认为您必须为此转置您的数据文件。无论如何,我发现这更明智,因为我不会使用聚类直方图,而是使用multiplot
:
set multiplot layout 1,3
fit
在 gnuplot 手册(版本 4.4)的第 57 章中描述,函数和表达式语法在第 13 章中描述,multiplot
在 gnuplot 手册(版本 4.4)的第 75.40 章中描述。
关于gnuplot - 在绘制为直方图的数据上叠加高斯形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5996602/