且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Matlab中在网格上绘制3D条形图

更新时间:2023-11-21 23:11:22

我同意@cris,有更好的方法来表示您的数据.但是,如果您仍然想使用3D条形图,则类似的方法会起作用:

I agree with @cris, there are better ways to represent your data. However, something like this would work if you still want to do use a 3D bar plot:

figure
hold on

for i = 1:5
    Ai = A(10*(i-1)+1:10*i,:);
    h = bar3(1:10,Ai,'stacked');

    for ih = 1 :length(h)
        x = get(h(ih), 'Xdata');
        set(h(ih), 'Xdata', x+i-1);
    end

end
view(3)