Matlab:指定轴上的3d条形图 [英] Matlab: 3d bar plot over specified axes

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

问题描述

Hallo SOers: 搜索了一会儿之后,答案仍然出现在我的问题中:
我有一个数据文件,例如:

Hallo SOers: After searching for a while, the answer still does show up for my question:
I have a data file like:

x  y     z
10 100   30
10 500   90
10 600   200
30 200   30
90 120   300
90 130   30
90 200   60

在matlab中,我想在(x,y)上绘制z,它们不是连续的点.绘图点应为条形图. 但是plot3()似乎不支持3D条形图,
和bar3()似乎不允许我指定我的(x,y)列.

In matlab, I want to plot z over (x, y), which are not continuous points. The plot point should be a bar. But plot3() seems do not support 3d bar plot,
and bar3() seems do not allow me to specify my (x,y) column.

那么如何获得这样的稀疏条形图?

So how to get such sparse bar plot?

非常感谢!

推荐答案

您可以将值放入矩阵中,其中每个元素代表一个条形.您可以将元素设置为值,而所有其他元素设置为零.

You could put the values into a Matrix where each element represents a bar. You set your elements to a value and all other elements to zero.

>> x = x./10    %I scaled the x and y values down by factor of 10


x =

     1     1     1     3     9     9     9

>> y = y./10

y =

    10    50    60    20    12    13    20


>> A = zeros(max(x),max(y));       %create Matrix of size 9x20
>> for i = 1:length(x)
A(x(i),y(i)) = z(i);               %populate the Matrix
end
>> bar3(A)
>> 

我确信您可以通过更改一些参数来使图更好,但这将是输出.

I am sure you could make the plot nicer by changing some parameters, but this would be the output.

这篇关于Matlab:指定轴上的3d条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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