I would like to plot several histograms in 3D using Matlab like in the below figure. Does anyone have any suggestions?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
2 commentaires
Réponses (2)
DGM
le 26 Fév 2023
Modifié(e) : DGM
le 26 Fév 2023
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 commentaires
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!