Plotting grouped 3D bars from 3D matrix
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!