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

6 次查看(过去 30 天)

回答(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