arrange multiple 2D histograms in 3D

21 views (last 30 days)
beginner on 14 Jul 2016
Answered: Duncan Po on 14 Jul 2016
I am wondering how I can draw this figure with Matlab. Please help!

Answers (1)

Duncan Po
Duncan Po on 14 Jul 2016
You can use the hist function to plot one histogram, then grab its vertices from the resulting patch object. Pass these vertices to the patch function and add a Z component to it. Like this:
h = get(gca,'Children');
x = h.Vertices(:,1);
y = h.Vertices(:,2);
z = 3*ones(size(x));
close all
h = get(gca,'Children');
x2 = h.Vertices(:,1);
y2 = h.Vertices(:,2);
z2 = 6*ones(size(x2));
close all;
patch(x,y,z, 'r'); hold on; patch(x2,y2,z2, 'b'); view(3)
% now rotate as desired

Community Treasure Hunt

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

Start Hunting!

Translated by