Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab-使用颜色条和标签紧密配合两个子图_Matlab_Labels_Subplot_Colorbar - Fatal编程技术网

Matlab-使用颜色条和标签紧密配合两个子图

Matlab-使用颜色条和标签紧密配合两个子图,matlab,labels,subplot,colorbar,Matlab,Labels,Subplot,Colorbar,我的问题在某种程度上与这个老问题有关(),但给出的答案并不令人满意 我想水平紧密地安装两个子图,第一个子图有一个有自己标签的色条 下面是它应该是什么样子 这是用来生成它的代码 h = figure('units','normalized','Position',[0,0,1,1]) ; ax(1) = subplot(1,2,1); hc = colorbar('EastOutside'); hc.Position(1) = ax(1).Position(1) + ax(1).Posit

我的问题在某种程度上与这个老问题有关(),但给出的答案并不令人满意

我想水平紧密地安装两个子图,第一个子图有一个有自己标签的色条

下面是它应该是什么样子

这是用来生成它的代码

h = figure('units','normalized','Position',[0,0,1,1]) ;

ax(1) = subplot(1,2,1);

hc = colorbar('EastOutside');

hc.Position(1) = ax(1).Position(1) + ax(1).Position(3)  ; % xfig + fig width

yl  = ylabel(hc,'$\sqrt{u^2 + v^2}$','interpreter','latex','Units','normalized','FontSize',16) ; % normalized with respect to the colorbar !

ext = yl.Extent ;

ti_lbrt(1,:) = ax(1).TightInset ; % Margins of the previous figure

ax(2) = subplot(1,2,2) ;

ti_lbrt(2,:) = ax(2).TightInset ; % Margins of the second figure


ax(2).Position(1) = ax(1).Position(1) + ax(1).Position(3) ...   lower right corner of previous figure
                    + ti_lbrt(1,3) ... right margin of the previous figure
                    + hc.Position(3) ... width of the colorbar
                    + ti_lbrt(2,1) ... % left margin of the new subplot
                    + ext(3)*hc.Position(3)...  width of the colorbar label
                    + 0.01 ; % Some arbitrary value; 
为什么我必须添加额外的0.01值以使其不重叠?

谢谢