3D bar graph of Z with data in X Y Z array
20 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (1 件)
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
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])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/696074/image.png)
Best, K
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!