No BSD License  

Highlights from
PLOTA

5.0

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

PLOTA

by Alex Bar-Guy

 

20 Oct 2005 (Updated 21 Oct 2005)

PLOTA plots each new plot using other color.

| Watch this File

File Information
Description

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 )

  EXAMPLE:
  figure;
  plota(randn(1,100));
  plota(randn(1,100));
  plota(randn(1,100));
  legend('First call to plota', 'Second call to plota', 'Third call to plota')

MATLAB release MATLAB 6.5.1 (R13SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
17 May 2006 David Sekyere  
18 Feb 2008 Natanya Black

Thank you - that was very helpful!!!

05 Mar 2008 Yonggun Jun

This is what I was looking for!!

11 Jan 2010 Rob Campbell

If your x axes have the same lengths then you don't need a new function. Just:
plot(randn(3,100)')
 
Also see:
http://blogs.mathworks.com/pick/2008/08/15/colors-for-your-multi-line-plots/

14 Jan 2010 IVAN

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

22 Jul 2010 Danilo Zanatta

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)

24 Sep 2010 Danilo Zanatta

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;
else
     ordi0 = length(get(ca,'Children'));
     CurrentHold = get( gca, 'NextPlot');
     set( gca, 'NextPlot', 'add' );
end
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), :));
end
if ordi0 == 0,
    set( gca, 'NextPlot', 'replace');
else
    set( gca, 'NextPlot', CurrentHold);
end

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
annotation Alex Bar-Guy 22 Oct 2008 08:03:31
customization Alex Bar-Guy 22 Oct 2008 08:03:31
plot Alex Bar-Guy 22 Oct 2008 08:03:31
figure Alex Bar-Guy 22 Oct 2008 08:03:31
color Alex Bar-Guy 22 Oct 2008 08:03:31
order Alex Bar-Guy 22 Oct 2008 08:03:31
hold Alex Bar-Guy 22 Oct 2008 08:03:31

Contact us at files@mathworks.com