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 Center および File ExchangeBar Plots についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by