问题描述
我有一些矩阵x1, x2, ...
,其中包含变量个行向量.我做了连续的情节
I have matrices x1, x2, ...
containing variable number of row vectors.I do successive plots
figure
hold all % or hold on
plot(x1')
plot(x2')
plot(x3')
Matlab或八度音阶通常会通过ColorOrder
进行迭代,并以不同的颜色绘制每行. 但是我希望每个plot
命令再次从颜色顺序中的第一种颜色开始,因此在默认情况下,矩阵中的第一个矢量应为蓝色,第二个应为绿色,第二个应为红色,等等.
Matlab or octave normally iterates through ColorOrder
and plot each line in different color. But I want each plot
command to start again with the first color in colororder, so in default case the first vector from matrix should be blue, second in green, third in red etc.
不幸的是,我找不到与颜色索引相关的任何属性,而没有其他方法可以重置它.
Unfortunately I cannot find any property related to the color index niether another method to reset it.
推荐答案
您可以在当前轴上移动原始的ColorOrder
,以便新图从相同的颜色开始:
You can shift the original ColorOrder
in current axes so that the new plot starts from the same color:
h=plot(x1');
set(gca, 'ColorOrder', circshift(get(gca, 'ColorOrder'), numel(h)))
plot(x2');
您可以将其包装在函数中:
You can wrap it in a function:
function h=plotc(X, varargin)
h=plot(X, varargin{:});
set(gca, 'ColorOrder', circshift(get(gca, 'ColorOrder'), numel(h)));
if nargout==0,
clear h
end
end
并致电
hold all
plotc(x1')
plotc(x2')
plotc(x3')
这篇关于重置ColorOrder索引以在Matlab/Octave中进行绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!