Home > atmlab > graphs > set_linestyle.m

set_linestyle

PURPOSE ^

SET_LINESTYLE Sets an (almost) unique line style

SYNOPSIS ^

function set_linestyle(h,n)

DESCRIPTION ^

 SET_LINESTYLE   Sets an (almost) unique line style

    The function sets a line style, based on the sequentail number given.
    An unique combination of line color and symbols are given for numbers
    between 1 and 70. To achieve this, a loop must be used.

    To plot each column of A with a different line style:
      for i=1:size(A,2)
        h = plot( x, A(:,i) );
        hold on
        set_linestyle( h, i );
      end

 FORMAT   set_linestyle( h, n )
        
 IN    h   Handle to line, or lines.
       n   A sequential number.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

set_linestyle.m

SOURCE CODE ^

0001 % SET_LINESTYLE   Sets an (almost) unique line style
0002 %
0003 %    The function sets a line style, based on the sequentail number given.
0004 %    An unique combination of line color and symbols are given for numbers
0005 %    between 1 and 70. To achieve this, a loop must be used.
0006 %
0007 %    To plot each column of A with a different line style:
0008 %      for i=1:size(A,2)
0009 %        h = plot( x, A(:,i) );
0010 %        hold on
0011 %        set_linestyle( h, i );
0012 %      end
0013 %
0014 % FORMAT   set_linestyle( h, n )
0015 %
0016 % IN    h   Handle to line, or lines.
0017 %       n   A sequential number.
0018 
0019 % 2006-10-19   Created by Patrick Eriksson.
0020 
0021 
0022 function set_linestyle(h,n)
0023 
0024 %= Define colors
0025 %
0026 c = [
0027  0.00 0.00 1.00;
0028  0.00 1.00 0.00;
0029  1.00 0.00 0.00;
0030  0.00 1.00 1.00;
0031  1.00 1.00 0.00;
0032  1.00 0.00 1.00;
0033  0.00 0.00 0.00;
0034  0.00 0.00 0.60;
0035  0.00 0.60 0.00;
0036  0.60 0.00 0.00;
0037  0.00 0.60 0.60;
0038  0.60 0.60 0.00;
0039  0.60 0.00 0.60;
0040  0.60 0.60 0.60;
0041 ];
0042 
0043 
0044 %= Define line styles
0045 %
0046 s = { '-', '--', '-.', '-', '-' };
0047 m = { 'none',  'none',   'none', '.', '*' };
0048 
0049 ic = rem( n-1, size(c,1) ) + 1;
0050 t  = ceil( n/size(c,1) );
0051 t= 1;
0052 is = rem( n-1, length(s) ) + 1;
0053 
0054 for i = 1:length(h)
0055   set( h(i), 'Color', c(ic,:), 'LineWidth', t, ...
0056                                           'LineStyle', s{is}, 'Marker', m{is} );
0057 end
0058  
0059

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005