gnuplot:如何从分布中产生平滑的密度图?

发布于 2025-02-01 09:10:30 字数 933 浏览 4 评论 0原文

我想从分布中制作一个密度图,例如第二个子图如下:

unset key

set yrange [0:]
set ytics 5

set print $data
do for [i = 1:100] { print rand(0)*10 }
unset print

binwidth = 1
set boxwidth 0.8*binwidth
# set fill style of bins
set style fill solid 0.5
# define macro for plotting the histogram
hist = 'u (binwidth*(floor(($1)/binwidth)+0.5)):(1.0) smooth freq w boxes'

density = 'u (binwidth*(floor(($1)/binwidth)+0.5)):(1.0) smooth freq with filledcurves y=0'

plot $data @density

example ://i.sstatic.net/yl4tm.png“ rel =“ nofollow noreferrer”>

它主要基于直方图,通过填充曲线添加,但一个明显的区别是,结果图根本不是平滑的

那么,如何从分布中产生光滑的密度图?是否可以在GNUPLOT中使用任何插值函数?

I would like to make a density plot from a distribution like the second subfigure in the following:

example

Here is what I tried:

unset key

set yrange [0:]
set ytics 5

set print $data
do for [i = 1:100] { print rand(0)*10 }
unset print

binwidth = 1
set boxwidth 0.8*binwidth
# set fill style of bins
set style fill solid 0.5
# define macro for plotting the histogram
hist = 'u (binwidth*(floor(($1)/binwidth)+0.5)):(1.0) smooth freq w boxes'

density = 'u (binwidth*(floor(($1)/binwidth)+0.5)):(1.0) smooth freq with filledcurves y=0'

plot $data @density

enter image description here

It is mainly based on a histogram by adding with filledcurves, but a clear difference is that the resulting figure is not smooth at all.

So, how can I generate smooth density plots from a distribution? Is there any interpolation function that can be used in gnuplot?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

姜生凉生 2025-02-08 09:10:30

我在gnuplot中发现内核密度估计在这里很有帮助。

plot $data u 1:(1/100.) s kdens bandwidth 1 with filledcurves y=0 

I found kernel density estimate in gnuplot can be helpful here.

plot $data u 1:(1/100.) s kdens bandwidth 1 with filledcurves y=0 

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文