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

2 vues (au cours des 30 derniers jours)
mingcheng nie
mingcheng nie le 25 Fév 2023
Réponse apportée : DGM le 25 Fév 2023
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.

Réponses (1)

DGM
DGM le 25 Fév 2023
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.

Tags

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by