我创建下图:
Naming = {'Name1','Name2','Name3','Name4','Name5','Name6'};
for i = 1:length(Naming);
dat = 1+(30-1).*rand(365,5);
time = datenum('2009-01-01','yyyy-mm-dd'):datenum('2009-12-31',...
'yyyy-mm-dd');
dept = 1:5;
figure(1);
ax = subplot(3,2,i);
contourf(time,dept,dat',1:5:30);
shading flat;
title(Naming{i});
datetick('x','mmm','keepticks');
AX{i} = get(ax,'position');
end
h = axes('Position',[0 0 1 1],'Visible','off');
c = colorbar;
x = get(c,'Position');
x(1) = AX{end}(1)+AX{end}(3)+0.02;
x(2) = AX{end}(2);
x(3) = 0.02;
x(4) = AX{1}(2)+AX{1}(4);
set(c,'Position',x);
有没有更好的方法来定义颜色条的宽度和高度?目前颜色条位于正确的位置,但高度太大。