3D bar graph of Z with data in X Y Z array
21 views (last 30 days)
Show older comments
FNU Dhanraj on 23 Jul 2021
Commented: FNU Dhanraj on 27 Jul 2021
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.
Konrad on 23 Jul 2021
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.
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!