Mercurial > octave-nkf
annotate scripts/image/rgbplot.m @ 15518:dee69050bb02
rgbplot.m: Tweak docstring.
* rgbplot.m: Tweak docstring.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 14 Oct 2012 09:01:34 -0700 |
parents | 3f1b306e2ba9 |
children | 168e380c8f18 |
rev | line source |
---|---|
14271
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
1 ## Copyright (C) 2012 Rik Wehbring |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
2 ## |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
4 ## |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
8 ## your option) any later version. |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
9 ## |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
13 ## General Public License for more details. |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
14 ## |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
18 |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
15517
3f1b306e2ba9
rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
20 ## @deftypefn {Function File} {} rgbplot (@var{cmap}) |
15518 | 21 ## @deftypefnx {Function File} {@var{h} =} rgbplot (@var{cmap}) |
14271
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
22 ## Plot the components of a colormap. |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
23 ## |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
24 ## The first column is plotted in red, the second column in green, and |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
25 ## the third column in blue. The values are between 0 and 1 and represent |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
26 ## the intensity of the RGB components in the given indexed color. |
15517
3f1b306e2ba9
rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
27 ## |
3f1b306e2ba9
rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
28 ## The optional return value @var{h} is a graphics handle to the created plot. |
3f1b306e2ba9
rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
29 ## |
14271
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
30 ## @seealso{colormap} |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
31 ## @end deftypefn |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
32 |
15517
3f1b306e2ba9
rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
33 function retval = rgbplot (cmap) |
14271
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
34 |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
35 if (nargin != 1) |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
36 print_usage (); |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
37 endif |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
38 |
15515
4beb3a4bd440
rgbplot.m, cmpermute.m, cmunique.m, ind2rgb.m, imwrite.m: use core iscolormap function
Carnë Draug <carandraug+dev@gmail.com>
parents:
14271
diff
changeset
|
39 if (! iscolormap (cmap)) |
4beb3a4bd440
rgbplot.m, cmpermute.m, cmunique.m, ind2rgb.m, imwrite.m: use core iscolormap function
Carnë Draug <carandraug+dev@gmail.com>
parents:
14271
diff
changeset
|
40 error ("rgbplot: CMAP must be a colormap"); |
14271
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
41 endif |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
42 |
15517
3f1b306e2ba9
rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
43 h = plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b"); |
14271
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
44 set (gca, 'ytick', 0:0.1:1); |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
45 xlabel ("color index"); |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
46 |
15517
3f1b306e2ba9
rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
47 if (nargout > 0) |
3f1b306e2ba9
rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
48 retval = h; |
3f1b306e2ba9
rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
49 endif |
3f1b306e2ba9
rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents:
15515
diff
changeset
|
50 |
14271
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
51 endfunction |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
52 |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
53 |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
54 %!demo |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
55 %! clf; |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
56 %! rgbplot (ocean); |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
57 |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
58 %%test input validation |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
59 %!error rgbplot () |
e2a14d1b4eaa
rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
60 %!error rgbplot (1,2) |
15515
4beb3a4bd440
rgbplot.m, cmpermute.m, cmunique.m, ind2rgb.m, imwrite.m: use core iscolormap function
Carnë Draug <carandraug+dev@gmail.com>
parents:
14271
diff
changeset
|
61 %!error <CMAP must be a colormap> rgbplot ({0 1 0}) |