3D bar graph of Z with data in X Y Z array

조회 수: 15 (최근 30일)
FNU Dhanraj
FNU Dhanraj 2021년 7월 23일
댓글: FNU Dhanraj 2021년 7월 27일
Hello,
I am having difficulty creating a 3D bar graph. I have the data in X Y Z array and need a 3d bar graph for Z.

답변 (1개)

Konrad
Konrad 2021년 7월 23일
Hi,
provided that x and y are always positive integers, this may be a good start:
tab = readtable('XYZ_Data.txt');
zarray = zeros(max(tab.Y),max(tab.X)); % you could also use NaNs
lind = sub2ind(size(zarray),tab.Y,tab.X);
zarray(lind) = tab.Z;
bar3(zarray); % you may want to reverse the direction of your z-axis if z is always <0
Note that I assume that there is only 1 z-value per x- & y- coordinate.
Best, Konrad
  댓글 수: 7
Konrad
Konrad 2021년 7월 27일
The main difference in this figure is that there are fewer bars visible. Constrain your x- and y-limit and your bars will look similar.
set(gca,'XLim',[60.5 75.5],'YLim',[60.5 75.5])
Best, K
FNU Dhanraj
FNU Dhanraj 2021년 7월 27일
Thanks Konrad

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by