Plotting grouped 3D bars from 3D matrix
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Omar Kamel
am 11 Jun. 2023
Kommentiert: Omar Kamel
am 11 Jun. 2023
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 Kommentare
Akzeptierte Antwort
Matt J
am 11 Jun. 2023
Bearbeitet: Matt J
am 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)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!