Matlab - 将colororder设置为默认值

时间:2016-06-22 14:02:30

标签: matlab

我正在使用以下代码

绘制数据
plot(x,y)
hold on
plot(x2,y2)

并且情节总是蓝色的。我尝试使用以下代码更改颜色顺序属性:

set(0, 'DefaultAxesColorOrder',co)

其中co是RGB矩阵,而不是我用以下函数检查颜色顺序:

get(0, 'DefaultAxesColorOrder')
get(gca,'colororder')

两者都返回我在全局设置之前的矩阵,但之前的情节总是保持蓝色,无论我使用函数来设置颜色顺序属性

[编辑#1] 这是get函数的输出

enter image description here

1 个答案:

答案 0 :(得分:0)

您的代码对我来说很好(MATLAB R2015a),除了我在绘图之前设置颜色。似乎set命令不会更新您的绘图,因为它可能无法理解绘图句柄。 我试过这个:

figure;
co = [0 0 0; 0.4, 0.4, 0.4; 0.7, 0.7, 0.7];
set(0,'DefaultAxesColorOrder',co)
plot([1 2],[1 2])
hold on;
plot([1,2],[1,3])

显示黑线和灰线。