comparison scripts/image/rgbplot.m @ 15517:3f1b306e2ba9

rgbplot: return graphics handle if requested
author Carnë Draug <carandraug+dev@gmail.com>
date Sat, 13 Oct 2012 21:53:21 +0200
parents 4beb3a4bd440
children dee69050bb02
comparison
equal deleted inserted replaced
15516:271f0a2d15ab 15517:3f1b306e2ba9
15 ## You should have received a copy of the GNU General Public License 15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see 16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>. 17 ## <http://www.gnu.org/licenses/>.
18 18
19 ## -*- texinfo -*- 19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} rgbplot (@var{cmap}) 20 ## @deftypefn {Function File} {} rgbplot (@var{cmap})
21 ## @deftypefnx {Function File} {@var{h} =} rgbplot (@dots{})
21 ## Plot the components of a colormap. 22 ## Plot the components of a colormap.
22 ## 23 ##
23 ## The first column is plotted in red, the second column in green, and 24 ## The first column is plotted in red, the second column in green, and
24 ## the third column in blue. The values are between 0 and 1 and represent 25 ## the third column in blue. The values are between 0 and 1 and represent
25 ## the intensity of the RGB components in the given indexed color. 26 ## the intensity of the RGB components in the given indexed color.
27 ##
28 ## The optional return value @var{h} is a graphics handle to the created plot.
29 ##
26 ## @seealso{colormap} 30 ## @seealso{colormap}
27 ## @end deftypefn 31 ## @end deftypefn
28 32
29 function rgbplot (cmap) 33 function retval = rgbplot (cmap)
30 34
31 if (nargin != 1) 35 if (nargin != 1)
32 print_usage (); 36 print_usage ();
33 endif 37 endif
34 38
35 if (! iscolormap (cmap)) 39 if (! iscolormap (cmap))
36 error ("rgbplot: CMAP must be a colormap"); 40 error ("rgbplot: CMAP must be a colormap");
37 endif 41 endif
38 42
39 plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b"); 43 h = plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b");
40 set (gca, 'ytick', 0:0.1:1); 44 set (gca, 'ytick', 0:0.1:1);
41 xlabel ("color index"); 45 xlabel ("color index");
46
47 if (nargout > 0)
48 retval = h;
49 endif
42 50
43 endfunction 51 endfunction
44 52
45 53
46 %!demo 54 %!demo