gnuplot直方图3d [英] Gnuplot histogram 3d

查看:65
本文介绍了gnuplot直方图3d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在3d中绘制直方图以生成类似此图的方式 http://www.gnuplot.info/demo/surface1.17.png ,但每个系列均为直方图.

I'm looking for a way to plot histograms in 3d to produce something like this figure http://www.gnuplot.info/demo/surface1.17.png but where each series is a histogram.

我正在使用此处给出的步骤 https://stackoverflow.com/a/19596160

I'm using the procedure given here https://stackoverflow.com/a/19596160 and http://www.gnuplotting.org/calculating-histograms/ to produce histograms, and it works perfectly in 2d. Basically, the commands I use are

hist = 'u (binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart):(1) smooth freq w boxes
plot 'data.txt' @hist

现在,我只想在同一图中添加多个直方图,但是由于它们在2d中重叠,因此我想在3d图中将它们隔开.

Now I would just like to add multiple histograms in the same plot, but because they overlap in 2d, I would like to space them out in a 3d plot.

我尝试执行以下命令(使用上述过程)

I have tried to do the following command (using above procedure)

hist = 'u (1):(binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart):(1) smooth freq w boxes
splot 'data.txt' @hist

但是gnuplot抱怨z值未定义.

But gnuplot complains that the z values are undefined.

我不明白为什么这样会不会在x轴上沿值1放置直方图,而在y轴上沿垃圾箱显示,而在z轴上绘制高度.

I don't understand why this would not put a histogram along the value 1 on the x-axis with the bins along the y-axis, and plot the height on the z-axis.

我的数据仅分为两列:

Index   angle
0       92.046      
1       91.331      
2       86.604      
3       88.446      
4       85.384      
5       85.975      
6       88.566      
7       90.575      

我有10个这样的文件,并且由于文件中的值彼此接近,如果将它们全部绘制在一个2d直方图中,它们将完全重叠.因此,我想以某种3D透视图看到彼此后面的10个直方图.

I have 10 files like this, and since the values in the files are close to each other, they will completely overlap if I plot them all in one 2d histogram. Therefore, I would like to see 10 histograms behind each other in a sort of 3d perspective.

推荐答案

第二个答案与我的第一个答案不同.第一个解决了OP试图完成的任务,而第二个解决方案提供了另一种方法来解决OP试图克服的潜在问题.

我已经发布了一个答案,该答案解决了在3d中执行此操作的能力.但是,这通常不是对像这样的多个直方图执行此操作的最佳方法.像这样的3d图形将很难比较.

I have posted an answer that addresses the ability to do this in 3d. However, this isn't usually the best way to do this with multiple histograms like this. A 3d graph like that will be difficult to compare.

我们可以通过停滞盒子的位置来解决2D中的重叠问题.使用默认设置时,这些框将展开以进行触摸.我们可以关闭它并调整框的位置,以允许图形上有多个1个直方图.请记住,您提供的坐标是框的中心.

We can address the overlap in 2D by stagnating the position of the boxes. With default settings, the boxes will spread out to touch. We can turn that off and adjust the position of the boxes to allow more than 1 histogram on a graph. Remember, that the coordinates you supply are the center of the boxes.

假设我有您提供的数据和此附加数据集

Suppose that I have the data you have provided and this additional data set

Index Angle
0  85.0804
1  92.2482
2  90.0384
3  99.2974
4  87.729
5  94.6049
6  86.703
7  97.9413

我们可以使用set boxwidth 2将boxwidth设置为2个单位(您的垃圾箱为4个单位宽).此外,我们将打开用填充的框.

We can set the boxwidth to 2 units with set boxwidth 2 (your bins are 4 units wide). Additionally, we will turn on box filling with set style fill solid border lc black.

然后我可以发出

plot datafile1 u (binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart):(1) smooth freq w boxes, \
     datafile2 u (binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart+1):(1) smooth freq w boxes

第二个绘图命令与第一个相同,除了binstart之后的+1.这会将此盒子向右移动1个单位.这会产生

The second plot command is identical to the first, except for the +1 after binstart. This will shift this box 1 unit to the right. This produces

这两个系列很清楚.由于存在重叠,因此很容易跟踪与每个框相关的框,但这不足以掩盖另一个框.

Here, the two series are clear. Keeping track of which box is associated with each is easy because of the overlap, but it is not enough to mask the other series.

我们甚至可以通过从第一个绘图命令中减去1来将它们彼此相邻地移动,而不会出现重叠:

We can even move them next to each other, with no overlap, by subtracting 1 from the first plot command:

plot datafile1 u (binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart-1):(1) smooth freq w boxes, \
     datafile2 u (binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart+1):(1) smooth freq w boxes

生产

这篇关于gnuplot直方图3d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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