你的
fig
是轴的手柄,而不是图形:
fig = subplot(2,1,1);
但是,当您设置
'defaultAxesColorOrder'
the docs
:
在地物级别设置默认值,以便新颜色仅影响作为地物子对象的轴
无花果
.
你需要做的就是定义
无花果
如图所示,并在设置
'DefaultAxesColorder'
属性:
fig = figure; %<-- you change here
left_color = [.5 .5 0];
right_color = [0 .5 .5];
set(fig,'defaultAxesColorOrder',[left_color; right_color]);
subplot(2,1,1) %<-- and add that
y = [1 2 3; 4 5 6];
yyaxis left
plot(y)
z = [6 5 4; 3 2 1];
yyaxis right
plot(z)