No BSD License  

Highlights from

5.0 | 5 ratings Rate this file 2 Downloads (last 30 days) File Size: 1.09 KB File ID: #8767 Version: 1.0
image thumbnail



Alex Bar-Guy (view profile)


20 Oct 2005 (Updated )

PLOTA plots each new plot using other color.

| Watch this File

File Information

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')

MATLAB release MATLAB 6.5.1 (R13SP1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
24 Sep 2010 daniloz

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);

Comment only
22 Jul 2010 daniloz

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)

14 Jan 2010 IVAN

IVAN (view profile)

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

11 Jan 2010 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:

Comment only
05 Mar 2008 Yonggun Jun

This is what I was looking for!!

18 Feb 2008 Natanya Black

Thank you - that was very helpful!!!

17 May 2006 David Sekyere  

Contact us