How to plot 3D bar graph?

조회 수: 19 (최근 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