1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <title>Description of colordg</title> |
---|
6 | <meta name="keywords" content="colordg"> |
---|
7 | <meta name="description" content="COLORDG - Provides a choice of 15 colors for a line plot"> |
---|
8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
9 | <meta name="generator" content="m2html © 2003 Guillaume Flandin"> |
---|
10 | <meta name="robots" content="index, follow"> |
---|
11 | <link type="text/css" rel="stylesheet" href="../../m2html.css"> |
---|
12 | </head> |
---|
13 | <body> |
---|
14 | <a name="_top"></a> |
---|
15 | <div><a href="../../index.html">Home</a> > <a href="#">applications</a> > <a href="index.html">common</a> > colordg.m</div> |
---|
16 | |
---|
17 | <!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png"> Master index</a></td> |
---|
18 | <td align="right"><a href="index.html">Index for applications/common <img alt=">" border="0" src="../../right.png"></a></td></tr></table>--> |
---|
19 | |
---|
20 | <h1>colordg |
---|
21 | </h1> |
---|
22 | |
---|
23 | <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
24 | <div class="box"><strong>COLORDG - Provides a choice of 15 colors for a line plot</strong></div> |
---|
25 | |
---|
26 | <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
27 | <div class="box"><strong>function linecolor = colordg(n); </strong></div> |
---|
28 | |
---|
29 | <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
30 | <div class="fragment"><pre class="comment">COLORDG - Provides a choice of 15 colors for a line plot |
---|
31 | The first seven colors are the same as Matlab's predefined |
---|
32 | values for the PLOT command, i.e. |
---|
33 | |
---|
34 | 'b','g','r','c','m','y','k' |
---|
35 | |
---|
36 | Syntax: linecolor = colordg(n); |
---|
37 | |
---|
38 | Input: N , integer between 1 and 15, giving the following colors |
---|
39 | |
---|
40 | 1 BLUE |
---|
41 | 2 GREEN (pale) |
---|
42 | 3 RED |
---|
43 | 4 CYAN |
---|
44 | 5 MAGENTA (pale) |
---|
45 | 6 YELLOW (pale) |
---|
46 | 7 BLACK |
---|
47 | 8 TURQUOISE |
---|
48 | 9 GREEN (dark) |
---|
49 | 10 YELLOW (dark) |
---|
50 | 11 ORANGE |
---|
51 | 12 MAGENTA (dark) |
---|
52 | 13 GREY |
---|
53 | 14 BROWN (pale) |
---|
54 | 15 BROWN (dark) |
---|
55 | |
---|
56 | Output: LINECOLOR (1 x 3 RGB vector) |
---|
57 | |
---|
58 | Examples: |
---|
59 | 1) h = line(x,y,'Color',colordg(11)); %Picks the orange color |
---|
60 | 2) colordg demo %Creates a figure displaying the 15 colors |
---|
61 | 3) axes; set(gca,'ColorOrder',(colordg(1:15))); |
---|
62 | Overrides the default ColorOrder for the current axes only |
---|
63 | 4) figure; set(gcf,'DefaultAxesColorOrder',(colordg(1:15))); |
---|
64 | Overrides the default ColorOrder for all axes of the current |
---|
65 | figure |
---|
66 | 5) set(0,'DefaultAxesColorOrder',(colordg(1:15))); |
---|
67 | Sets the default ColorOrder for all axes to be created during |
---|
68 | the current matlab session. You may wish to insert this |
---|
69 | command into your startup.m file. |
---|
70 | |
---|
71 | See also: PLOT, LINE, AXES</pre></div> |
---|
72 | |
---|
73 | <!-- crossreference --> |
---|
74 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
75 | This function calls: |
---|
76 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
77 | </ul> |
---|
78 | This function is called by: |
---|
79 | <ul style="list-style-image:url(../../matlabicon.gif)"> |
---|
80 | </ul> |
---|
81 | <!-- crossreference --> |
---|
82 | |
---|
83 | |
---|
84 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2> |
---|
85 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function linecolor = colordg(n);</a> |
---|
86 | 0002 <span class="comment">%COLORDG - Provides a choice of 15 colors for a line plot</span> |
---|
87 | 0003 <span class="comment">%The first seven colors are the same as Matlab's predefined</span> |
---|
88 | 0004 <span class="comment">%values for the PLOT command, i.e.</span> |
---|
89 | 0005 <span class="comment">%</span> |
---|
90 | 0006 <span class="comment">% 'b','g','r','c','m','y','k'</span> |
---|
91 | 0007 <span class="comment">%</span> |
---|
92 | 0008 <span class="comment">%Syntax: linecolor = colordg(n);</span> |
---|
93 | 0009 <span class="comment">%</span> |
---|
94 | 0010 <span class="comment">%Input: N , integer between 1 and 15, giving the following colors</span> |
---|
95 | 0011 <span class="comment">%</span> |
---|
96 | 0012 <span class="comment">% 1 BLUE</span> |
---|
97 | 0013 <span class="comment">% 2 GREEN (pale)</span> |
---|
98 | 0014 <span class="comment">% 3 RED</span> |
---|
99 | 0015 <span class="comment">% 4 CYAN</span> |
---|
100 | 0016 <span class="comment">% 5 MAGENTA (pale)</span> |
---|
101 | 0017 <span class="comment">% 6 YELLOW (pale)</span> |
---|
102 | 0018 <span class="comment">% 7 BLACK</span> |
---|
103 | 0019 <span class="comment">% 8 TURQUOISE</span> |
---|
104 | 0020 <span class="comment">% 9 GREEN (dark)</span> |
---|
105 | 0021 <span class="comment">% 10 YELLOW (dark)</span> |
---|
106 | 0022 <span class="comment">% 11 ORANGE</span> |
---|
107 | 0023 <span class="comment">% 12 MAGENTA (dark)</span> |
---|
108 | 0024 <span class="comment">% 13 GREY</span> |
---|
109 | 0025 <span class="comment">% 14 BROWN (pale)</span> |
---|
110 | 0026 <span class="comment">% 15 BROWN (dark)</span> |
---|
111 | 0027 <span class="comment">%</span> |
---|
112 | 0028 <span class="comment">%Output: LINECOLOR (1 x 3 RGB vector)</span> |
---|
113 | 0029 <span class="comment">%</span> |
---|
114 | 0030 <span class="comment">%Examples:</span> |
---|
115 | 0031 <span class="comment">% 1) h = line(x,y,'Color',colordg(11)); %Picks the orange color</span> |
---|
116 | 0032 <span class="comment">% 2) colordg demo %Creates a figure displaying the 15 colors</span> |
---|
117 | 0033 <span class="comment">% 3) axes; set(gca,'ColorOrder',(colordg(1:15)));</span> |
---|
118 | 0034 <span class="comment">% Overrides the default ColorOrder for the current axes only</span> |
---|
119 | 0035 <span class="comment">% 4) figure; set(gcf,'DefaultAxesColorOrder',(colordg(1:15)));</span> |
---|
120 | 0036 <span class="comment">% Overrides the default ColorOrder for all axes of the current</span> |
---|
121 | 0037 <span class="comment">% figure</span> |
---|
122 | 0038 <span class="comment">% 5) set(0,'DefaultAxesColorOrder',(colordg(1:15)));</span> |
---|
123 | 0039 <span class="comment">% Sets the default ColorOrder for all axes to be created during</span> |
---|
124 | 0040 <span class="comment">% the current matlab session. You may wish to insert this</span> |
---|
125 | 0041 <span class="comment">% command into your startup.m file.</span> |
---|
126 | 0042 <span class="comment">%</span> |
---|
127 | 0043 <span class="comment">%See also: PLOT, LINE, AXES</span> |
---|
128 | 0044 |
---|
129 | 0045 <span class="comment">%Author: Denis Gilbert, Ph.D., physical oceanography</span> |
---|
130 | 0046 <span class="comment">%Maurice Lamontagne Institute, Dept. of Fisheries and Oceans Canada</span> |
---|
131 | 0047 <span class="comment">%Web: http://www.qc.dfo-mpo.gc.ca/iml/</span> |
---|
132 | 0048 <span class="comment">%August 2000; Last revision: 26-Sep-2003</span> |
---|
133 | 0049 |
---|
134 | 0050 <span class="keyword">if</span> nargin == 0 |
---|
135 | 0051 error(<span class="string">'Must provide an input argument to COLORDG'</span>) |
---|
136 | 0052 <span class="keyword">end</span> |
---|
137 | 0053 |
---|
138 | 0054 colorOrder = <span class="keyword">...</span> |
---|
139 | 0055 [ 0 0 1 <span class="comment">% 1 BLUE</span> |
---|
140 | 0056 0 1 0 <span class="comment">% 2 GREEN (pale)</span> |
---|
141 | 0057 1 0 0 <span class="comment">% 3 RED</span> |
---|
142 | 0058 0 1 1 <span class="comment">% 4 CYAN</span> |
---|
143 | 0059 1 0 1 <span class="comment">% 5 MAGENTA (pale)</span> |
---|
144 | 0060 1 1 0 <span class="comment">% 6 YELLOW (pale)</span> |
---|
145 | 0061 0 0 0 <span class="comment">% 7 BLACK</span> |
---|
146 | 0062 0 0.75 0.75 <span class="comment">% 8 TURQUOISE</span> |
---|
147 | 0063 0 0.5 0 <span class="comment">% 9 GREEN (dark)</span> |
---|
148 | 0064 0.75 0.75 0 <span class="comment">% 10 YELLOW (dark)</span> |
---|
149 | 0065 1 0.50 0.25 <span class="comment">% 11 ORANGE</span> |
---|
150 | 0066 0.75 0 0.75 <span class="comment">% 12 MAGENTA (dark)</span> |
---|
151 | 0067 0.7 0.7 0.7 <span class="comment">% 13 GREY</span> |
---|
152 | 0068 0.8 0.7 0.6 <span class="comment">% 14 BROWN (pale)</span> |
---|
153 | 0069 0.6 0.5 0.4 ]; <span class="comment">% 15 BROWN (dark)</span> |
---|
154 | 0070 |
---|
155 | 0071 <span class="keyword">if</span> isnumeric(n) & n >= 1 & n <= 15 |
---|
156 | 0072 linecolor = colorOrder(n,:); |
---|
157 | 0073 <span class="keyword">elseif</span> strcmp(n,<span class="string">'demo'</span>) |
---|
158 | 0074 <span class="comment">%GENERATE PLOT to display a sample of the line colors</span> |
---|
159 | 0075 figure, axes; |
---|
160 | 0076 <span class="comment">%PLOT N horizontal lines</span> |
---|
161 | 0077 <span class="keyword">for</span> n=1:length(colorOrder) |
---|
162 | 0078 h(n) = line([0 1],[n n],<span class="string">'Color'</span>,colorOrder(n,:)); |
---|
163 | 0079 <span class="keyword">end</span> |
---|
164 | 0080 set(h,<span class="string">'LineWidth'</span>,5) |
---|
165 | 0081 set(gca,<span class="string">'YLim'</span>,[0 n+1],<span class="string">'YTick'</span>,[1:n],<span class="string">'XTick'</span>,[]) |
---|
166 | 0082 ylabel(<span class="string">'Color Number'</span>); |
---|
167 | 0083 <span class="keyword">else</span> |
---|
168 | 0084 error(<span class="string">'Invalid input to colordg'</span>); |
---|
169 | 0085 <span class="keyword">end</span> |
---|
170 | 0086</pre></div> |
---|
171 | <hr><address>Generated on Mon 21-May-2007 15:32:41 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
172 | </body> |
---|
173 | </html> |
---|