Reset ColorOrder index for plotting in Matlab / Octave

前端 未结 5 1287
独厮守ぢ
独厮守ぢ 2021-02-07 15:47

I have matrices x1, x2, ... containing variable number of row vectors. I do successive plots

figure
hold all % or hold on
plot(x1\'         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-07 16:15

    Define a function that intercepts the call to plot and sets 'ColorOrderIndex' to 1 before doing the actual plot.

    function plot(varargin)
    if strcmp(class(varargin{1}), 'matlab.graphics.axis.Axes')
        h = varargin{1}; %// axes are specified
    else
        h = gca; %// axes are not specified: use current axes
    end
    set(h, 'ColorOrderIndex', 1) %// reset color index
    builtin('plot', (varargin{:})) %// call builtin plot function
    

    I have tested this in Matlab R2014b.

提交回复
热议问题