Hello José,
I hope I've understood you correctly. Do you want bars to be cubes which edges are given by array 'values'? If so, I think it is possible to manipulate XData and YData of the bars. Check out this code below (I've edited yours). With a few changes to it, I think you will get what you want.
values = [1.0 0.6 0.1; 0.0 1.0 0.3; 0.9 0.4 1.0];
h = bar3(values);
shading interp
for i = 1:length(h)
zdata = get(h(i),'Zdata');
set(h(i),'Cdata',zdata);
xdata = get(h(i),'XData');
ydata = get(h(i),'YData');
xmat = [nan -1 1 nan;
-1 -1 1 1;
-1 -1 1 1;
nan -1 1 nan;
nan -1 1 nan;
nan nan nan nan];
ymat = [nan -1 -1 nan;
-1 -1 -1 -1;
1 1 1 1;
nan 1 1 nan;
nan -1 -1 nan;
nan nan nan nan];
xdata=xdata-.5*kron(1-values(:,i),xmat);
ydata=ydata-.5*kron(1-values(:,i),ymat);
set(h(i),'XData',xdata,'YData',ydata);
end
set(h,'EdgeColor','k')
view(-61, 68);
colormap cool
colorbar
Best Answer