我只是遇到一个奇怪的行为,那就是如果使用yyaxis
似乎无法更改MATLAB中的图的堆叠方式。
标准订单(为清楚起见,增加了行宽):
%% standard order
% open figure
figure('Name','layers: order (left,right)');
% create axis's handle / draw axis
ax = subplot(1,1,1);
% plot on left side
yyaxis( ax,'left')
plot( ax,[1,2],[1,2],'LineWidth',10)
% plot on right side
yyaxis( ax,'right')
plot( ax,[0,4],[1,2],'LineWidth',10)
现在尝试通过更改打印顺序简单地在左侧上绘制右侧
%% independent of the order
% open new figure
figure('Name','layers: order (right,left)');
% create axis's handle / draw axis
ax = subplot(1,1,1);
% plot on right side
yyaxis( ax,'right')
plot( ax,[0,4],[1,2],'LineWidth',10)
% plot on left side
yyaxis( ax,'left')
plot( ax,[1,2],[1,2],'LineWidth',10)
我尝试手动将层的顺序更改为this post suggested:
%% set layer?
% open new figure
figure('Name','layers: set (right,left)');
% create axis's handle / draw axis
ax = subplot(1,1,1);
% plot on right side
yyaxis( ax,'right')
plot( ax,[0,4],[1,2],'LineWidth',10)
% plot on left side
yyaxis( ax,'left')
plot( ax,[1,2],[1,2],'LineWidth',10)
set(ax ,'Layer', 'Top')
% set(gca ,'Layer', 'Top')
这是MATLAB R2019b。似乎The Mathworks knows this issue自2016年以来,我想知道在此期间是否有修复/扩展,但我只是忽略了。