Is there any plot function that perform a plan view of bar3?

2 次查看(过去 30 天)
if we have a square matrix H=randi(N,N)+1i*randi(N,N); I want to see the plan view of bar3(abs(H)), especially, for the same amplitude of entries in H, I want them have the same color. By the way, I don't think pcolor will work because pcolor plot the abs(H) at grid point instead of square area.

回答(1 个)

DGM
DGM 2023-2-25
This sounds like a use for imagesc(). While surf()/pcolor() associate the data values with the vertices, image()/imagesc() associate the data with the face centers.
N = 5;
H = magic(5)
H = 5×5
17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
% a bar3 plot with bar colors matching z-height
hb = bar3(abs(H));
for k = 1:numel(hb)
c = permute(reshape(hb(k).ZData,6,5,4),[1 3 2]);
c = permute(repmat(max(c,[],[1 2]),[6 4 1]),[1 3 2]);
hb(k).CData(:) = reshape(c,[],4);
end
% using imagesc() instead
figure
imagesc(H)
Of course, if you want the gaps between the faces, that might be a different story.

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by