How to plot 3D bar graph?

17 次查看(过去 30 天)
Stephen
Stephen 2019-6-26
评论: Stephen 2019-6-26
I've searched but can't find the solution on how to plot the following as a 3D graph. I have a matrix of x,y,z values, e.g.:
Capture.JPG
I want to generate a 3D plot in all 3 dimensions, with y as the height of the bar and z as the width, such as the following (not drawn to scale...I just kluged it together in powerpoint):
Capture.JPG
How do I do this? none of the following worked:
bar3(x,y,z)
bar3(z)
bar3(x,y)
bar3(y,z)

回答(2 个)

sourav  malla
sourav malla 2019-6-26
You can find the details in the documentation here:-
  1 个评论
Stephen
Stephen 2019-6-26
nah, tried that. I can't find any answer on that page

请先登录,再进行评论。


KALYAN ACHARJYA
KALYAN ACHARJYA 2019-6-26
编辑:KALYAN ACHARJYA 2019-6-26
You can use this custom function
scatterbar3(x,y,z,0.5)
grid on
For example
x=1:10;
y=2:2:20;
z=3:3:30;
scatterbar3(x,y,z,0.5)
grid on
99.png
  1 个评论
Stephen
Stephen 2019-6-26
Thanks, Kalyan! Close, but no banana. For instance, for the following matrix:
1 1.00 3.43
2 1.00 3.24
3 1.00 3.20
4 0.91 3.15
5 0.69 3.07
6 1.00 2.82
7 1.00 2.76
8 1.00 2.62
9 1.00 2.61
10 0.68 2.55
I ran the following:
x=matrix(:,1);
y=matrix(:,2);
z=matrix(:,3);
scatterbar3(x,y,z,1)
I get this fig (ignore the colors, I'll fix that later):Capture.JPG
The z dimension (0.0 to 3.0) is accurate (the height of each bar), and the x sequence (1 to 10) is shown correctly, but the widths of the bars, y, are all fixed (=1). I need the "base" of all the bars to start at y=0 and the bar's width extend up to the corresponding value of y for each entry. In short, the width should = y, not a constant.
Any ideas?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Bar Plots 的更多信息

产品


版本

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by