Plotting grouped 3D bars from 3D matrix

7 ビュー (過去 30 日間)
Omar Kamel
Omar Kamel 2023 年 6 月 11 日
コメント済み: Omar Kamel 2023 年 6 月 11 日
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!

採用された回答

Matt J
Matt J 2023 年 6 月 11 日
編集済み: Matt J 2023 年 6 月 11 日
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)
  1 件のコメント
Omar Kamel
Omar Kamel 2023 年 6 月 11 日
Thanks a lot, Matt! This is exactly what I am looking for!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by