I would like to plot several histograms in 3D using Matlab like in the below figure. Does anyone have any suggestions?
조회 수: 4 (최근 30일)
이전 댓글 표시
답변 (2개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!