I would like to plot several histograms in 3D using Matlab like in the below figure. Does anyone have any suggestions?

조회 수: 4 (최근 30일)
  댓글 수: 2
Heri
Heri 2023년 2월 25일
Thanks for your answer, Joshi. I try to use bar3, but the output is not appropriate with what I want. Perhaps you have code to plot a figure like I asked previously.

댓글을 달려면 로그인하십시오.

답변 (2개)

Cameron
Cameron 2023년 2월 23일
  댓글 수: 1
Heri
Heri 2023년 2월 25일
Thanks for your answer, Cameron. You suggest to check out a solution using fill3. However, the way to plot several histograms is different from fill3 command, since syntax for bar3, histogram2, hist3 is not like fill3 which uses 3 vectors, i.e., X, Y, and Z in each coordinate axis.

댓글을 달려면 로그인하십시오.


DGM
DGM 2023년 2월 26일
편집: DGM 2023년 2월 26일
I could have sworn I'd posted an answer to a similar problem, but maybe I'm dreaming. Here's one way of doing it with bar3().
% say you have some data
% i'm just going to use channel histograms from an image
inpict = imread('peppers.png');
nbins = 64;
counts = zeros(nbins,3);
for c = 1:3
[counts(:,c),~] = imhist(inpict(:,:,c),nbins);
end
% plot them using bar3()
xoffset = [0 10 20];
alpha = 0.5;
hb = bar3(counts);
for k = 1:numel(hb)
hb(k).XData(:) = xoffset(k);
hb(k).FaceAlpha = alpha;
hb(k).LineStyle = 'none';
end
xticks(xoffset)
colormap(hsv(numel(hb))) % or pick whatever map you want
% adjust dataaspect to force spacing on x
xscalefactor = 2; % adjust me
yl = ylim; % store for later
hax = gca;
hax.DataAspectRatio(1) = hax.DataAspectRatio(1)/xscalefactor;
% clean up view
ylim(yl)
xlim(xoffset([1 end]))
view(-55,20)
While bar3 allows a Y parameter, that seems to really only be useful for setting the position of data groups, not series. Given that, I don't see a simple way to do this without a bunch of direct manipulation of the individual surf objects.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by