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

2 ビュー (過去 30 日間)
mingcheng nie
mingcheng nie 2023 年 2 月 25 日
回答済み: DGM 2023 年 2 月 25 日
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 Center および File ExchangeSurface 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