Plotting grouped 3D bars from 3D matrix
11 views (last 30 days)
Show older comments
Dear Matlab Community,
I have a 3D matrix (rows=5, cols=4, planes=5) where rows represent different simulation conditions (1 to 5 values on the x-axis), columns represent different simulation approaches (4 colors in the attached plots) and planes represent different parameterization (δ in the attached plot). I created the attached plot using tiled layout where I loop over the 3rd index of the matrix and plot the corresponding 2D matrix using grouped bar3 plot, but I want to merge them all in one 3D bar plot where I want each color to represent a column and combine the variation in δ into the y-axis.
Thanks in advance for your help!
0 Comments
Accepted Answer
Matt J
on 11 Jun 2023
Edited: Matt J
on 11 Jun 2023
Perhaps as follows:
z=rand(5,4,5);%Fake data
numDelta=size(z,3);
clear xtk
for i=1:numDelta
h=bar3(z(:,:,i),'grouped'); hold on
for j=1:numel(h)
h(j).XData=h(j).XData+(i-1);
end
xtk(i)=mean([h.XData],'all','omitnan');
end
hold off; axis padded, axis equal
zlabel z, ylabel y, xlabel('\delta')
xticks(xtk); xticklabels(string((1:numDelta)*0.05));
view(25,30)
More Answers (0)
See Also
Categories
Find more on Annotations 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!