File Exchange

image thumbnail


version 1.0 (1.09 KB) by

PLOTA plots each new plot using other color.

1 Download


No License

PLOTA is the same as standard PLOT function, BUT it plots each new plot using other color ( making 'hold on' automatically and cycling through the colors in the order specified by the current axes ColorOrder property )

  legend('First call to plota', 'Second call to plota', 'Third call to plota')

Comments and Ratings (7)


Sorry, I made a mistake on my previous comment (is it possible to edit/delete it)... The function should be:

ca = get(get(0,'CurrentFigure'),'CurrentAxes');
if isempty( ca )
     ordi0 = 0;
     ordi0 = length(get(ca,'Children'));
     CurrentHold = get( gca, 'NextPlot');
     set( gca, 'NextPlot', 'add' );
hp = plot( varargin{:} );
ColOrd = get(gca, 'ColorOrder');
children = get(gca,'Children');
ordi = length(children);
ord = mod((ordi0+1:ordi)-1, size(ColOrd,1));
cc = 0;
for ii = (ordi - ordi0): -1 : 1
     cc = cc + 1;
     set(children(ii), 'Color', ColOrd(((ordi0+cc)<=size(ColOrd,1))*(ordi0+cc) + ((ordi0+cc)>size(ColOrd,1))*(ord(cc)+1), :));
if ordi0 == 0,
    set( gca, 'NextPlot', 'replace');
    set( gca, 'NextPlot', CurrentHold);


Thank you - very helpful tool !!!!

Just a comment: sine I often use handles to plots, I've change the function definition to:

function hp = plota(varargin)


IVAN (view profile)

This is perfect! I´m very grateful for this function

Rob Campbell

Rob Campbell (view profile)

If your x axes have the same lengths then you don't need a new function. Just:
Also see:

Yonggun Jun

This is what I was looking for!!

Natanya Black

Thank you - that was very helpful!!!

David Sekyere

MATLAB Release
MATLAB 6.5.1 (R13SP1)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video