gpt4 book ai didi

gnuplot - gnuplot 中的水平直方图

转载 作者:行者123 更新时间:2023-12-02 18:30:15 30 4
gpt4 key购买 nike

我正在尝试在 gnuplot 中绘制水平直方图。

这是我当前的垂直(通常类型)直方图:

width=0.5
hist(x,width)=width*floor(x/width)+width/2.0
set boxwidth width*0.9
set style fill solid 0.5
plot "a" u (hist($2,width)):(1.0) smooth freq w boxes lc 3 notitle

现在我需要的是完全相同的结果,但顺时针旋转 90 度。

我在下面尝试过,但结果确实不是我所期望的。

width=0.5
hist(x,width)=width*floor(x/width)+width/2.0
set boxwidth width*0.9
set style fill solid 0.5
plot "a" u (1.0):(hist($2,width)) smooth freq w boxes lc 3 notitle

最佳答案

虽然这个问题相当老了,而且基本上得到了回答(但是,没有被接受),但让我提供一个带有插图的更新,仅供记录。

据我所知,在当前的gnuplot(5.4.0)中仍然没有专用的水平直方图样式,可能是因为您可以简单地使用boxxyerror(如果您知道如何)来实现它在用户 @pygrac 和 @adhip agarwala 的答案以及 @Christoph 链接的答案中提到。因此,没有必要创建垂直直方图并旋转它,因为绘图样式 boxxyerror 已经存在于 gnuplot 4.0 (2004) 甚至更早的版本中。

由于 gnuplot 5.0.0 (2015) 数据 block 可用,因此不再需要将直方图数据 smooth freq 写入磁盘上的文件中。

代码:

### horizontal histogram (gnuplot >=5.0.0)
reset session

# create some random test data
set table $Data
set samples 2000
plot '+' u 1:(invnorm(rand(0))+2) w table
set samples 1000
plot '+' u 1:(invnorm(rand(0))-2) w table
unset table

binwidth = 0.25
bin(x) = binwidth * floor(x/binwidth)

set table $Histo
plot $Data u (bin($2)):(1) smooth freq
unset table

set style fill transparent solid 0.5

plot $Histo u (0):1:(0):2:($1-binwidth/2.):($1+binwidth/2.) w boxxy ti "Horizontal Histogram"
### end of code

结果:

enter image description here

关于gnuplot - gnuplot 中的水平直方图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11266452/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com