Tools for Axis Label Alignment in 3D Plot https://www.mathworks.com/matlabcentral/fileexchange/49542-tools-for-axis-label-alignment-in-3d-plot
這是目前最好的3D繪圖xlable, ylable對齊的解決方法。請到上述Mathworks網站自行下載,添加到自己Matlab的path,即可使用。
使用時在你surf繪圖的程序語句后增加以下語句,可以實現繪圖后的對齊,以及手動旋轉圖片時的自動對齊:
ax = struct('Axes', gca);
align_axislabel([],ax)
h3d = rotate3d;
set(h3d,'ActionPreCallback','set(gcf,''windowbuttonmotionfcn'',@align_axislabel)');
set(h3d,'ActionPostCallback','set(gcf,''windowbuttonmotionfcn'','''')');
實現結果