满意答案
lastdargo
推荐于 2016.01.18
采纳率:45% 等级:10
已帮助:818人
一、利用bar3画一个矩阵的柱状图时,如何改变显示的颜色,让它根据数据大小的不同显示不同的颜色,比如数据越大颜色越深,而不是bar3内置的颜色那样沿x轴或y轴渐变。可以试着用以下的方法实现:
M=rand(30,20);
figure
subplot(1,2,1)
h=bar3(M)
for n=1:numel(h)
cdata=get(h(n),'zdata');
set(h(n),'cdata',cdata,'facecolor','interp')
end
subplot(1,2,2)
h=bar3(M)
for n=1:numel(h)
cdata=get(h(n),'zdata');
cdata&