annotate scripts/image/rgbplot.m @ 17170:d6499c14021c

doc: Periodic grammarcheck of documentation. * doc/interpreter/basics.txi, doc/interpreter/expr.txi, doc/interpreter/install.txi, doc/interpreter/java.txi, doc/interpreter/plot.txi, doc/interpreter/sparse.txi, doc/interpreter/vectorize.txi, libinterp/corefcn/cellfun.cc, libinterp/corefcn/debug.cc, libinterp/corefcn/file-io.cc, libinterp/corefcn/load-save.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/pr-output.cc, libinterp/parse-tree/oct-parse.in.yy, liboctave/numeric/LSODE-opts.in, scripts/image/imformats.m, scripts/image/imread.m, scripts/image/imwrite.m, scripts/miscellaneous/error_ids.m, scripts/miscellaneous/fileattrib.m, scripts/miscellaneous/mex.m, scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/warning_ids.m, scripts/prefs/prefdir.m, scripts/prefs/preferences.m, scripts/signal/fftfilt.m, scripts/strings/isstrprop.m, scripts/testfun/assert.m: Periodic grammarcheck of documentation.
author Rik <rik@octave.org>
date Sun, 04 Aug 2013 13:08:39 -0700
parents 7268845c0a1e
children d63878346099
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
2 ## Copyright (C) 2012 Carnë Draug
14271
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
3 ##
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
4 ## 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
5 ##
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
6 ## 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
7 ## 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
8 ## 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
9 ## your option) any later version.
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
10 ##
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
11 ## 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
12 ## 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
13 ## 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
14 ## 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
15 ##
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
16 ## 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
17 ## 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
18 ## <http://www.gnu.org/licenses/>.
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
19
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
20 ## -*- texinfo -*-
15517
3f1b306e2ba9 rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents: 15515
diff changeset
21 ## @deftypefn {Function File} {} rgbplot (@var{cmap})
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
22 ## @deftypefnx {Function File} {} rgbplot (@var{cmap}, @var{style})
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
23 ## @deftypefnx {Function File} {@var{h} =} rgbplot (@dots{})
14271
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
24 ## 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
25 ##
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
26 ## Two different @var{style}s are available for displaying the @var{cmap}:
15715
6ae93518356c rgbplot.m. Match variable in docstring to function prototype.
Rik <rik@octave.org>
parents: 15714
diff changeset
27 ##
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
28 ## @table @asis
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
29 ## @item profile (default)
15715
6ae93518356c rgbplot.m. Match variable in docstring to function prototype.
Rik <rik@octave.org>
parents: 15714
diff changeset
30 ## Plot the RGB line profile of the colormap for each of the channels (red,
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
31 ## green and blue) with the plot lines colored appropriately. Each line
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
32 ## represents the intensity of each RGB components across the colormap.
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
33 ##
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
34 ## @item composite
15715
6ae93518356c rgbplot.m. Match variable in docstring to function prototype.
Rik <rik@octave.org>
parents: 15714
diff changeset
35 ## Draw the colormap across the X-axis so that the actual index colors are
6ae93518356c rgbplot.m. Match variable in docstring to function prototype.
Rik <rik@octave.org>
parents: 15714
diff changeset
36 ## visible rather than the individual color components.
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
37 ##
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
38 ## @end table
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
39 ##
15517
3f1b306e2ba9 rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents: 15515
diff changeset
40 ## 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
41 ##
15716
e8a4b99f8bd8 Correct typo in docstring in changeset 6ae93518356c.
Ben Abbott <bpabbott@mac.com>
parents: 15715
diff changeset
42 ## Run @code{demo rgbplot} to see an example of @code{rgbplot} and each style
15715
6ae93518356c rgbplot.m. Match variable in docstring to function prototype.
Rik <rik@octave.org>
parents: 15714
diff changeset
43 ## option.
14271
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
44 ## @seealso{colormap}
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
45 ## @end deftypefn
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
46
16472
293f5479a7e7 rgbplot.m: Set the default style to "profile"
Rik <rik@octave.org>
parents: 15716
diff changeset
47 function h = rgbplot (cmap, style = "profile")
14271
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
48
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
49 if (nargin < 1 || nargin > 2)
14271
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
50 print_usage ();
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
51 endif
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
52
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
53 if (! iscolormap (cmap))
15714
b1cd65881592 Clean up scripts in image directory.
Rik <rik@octave.org>
parents: 15713
diff changeset
54 error ("rgbplot: CMAP must be a valid colormap");
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
55 elseif (! ischar (style))
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
56 error ("rgbplot: STYLE must be a string");
14271
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
57 endif
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
58
15715
6ae93518356c rgbplot.m. Match variable in docstring to function prototype.
Rik <rik@octave.org>
parents: 15714
diff changeset
59 switch (tolower (style))
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
60 case "profile"
15715
6ae93518356c rgbplot.m. Match variable in docstring to function prototype.
Rik <rik@octave.org>
parents: 15714
diff changeset
61 htmp = plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b");
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
62 set (gca, 'ytick', 0:0.1:1);
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
63 case "composite"
15715
6ae93518356c rgbplot.m. Match variable in docstring to function prototype.
Rik <rik@octave.org>
parents: 15714
diff changeset
64 htmp = image (1:rows(cmap));
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
65 set (gca, 'ytick', []);
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
66 colormap (cmap);
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
67 otherwise
16766
7268845c0a1e avoid backquote in error messages, some uses in doc strings
John W. Eaton <jwe@octave.org>
parents: 16472
diff changeset
68 error ("rgbplot: unknown style '%s'", style);
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
69 endswitch
14271
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
70 xlabel ("color index");
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
71
15517
3f1b306e2ba9 rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents: 15515
diff changeset
72 if (nargout > 0)
15714
b1cd65881592 Clean up scripts in image directory.
Rik <rik@octave.org>
parents: 15713
diff changeset
73 h = htmp;
15517
3f1b306e2ba9 rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents: 15515
diff changeset
74 endif
3f1b306e2ba9 rgbplot: return graphics handle if requested
Carnë Draug <carandraug+dev@gmail.com>
parents: 15515
diff changeset
75
14271
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
76 endfunction
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
77
15715
6ae93518356c rgbplot.m. Match variable in docstring to function prototype.
Rik <rik@octave.org>
parents: 15714
diff changeset
78
14271
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
79 %!demo
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
80 %! clf;
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
81 %! subplot (1, 2, 1);
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
82 %! rgbplot (ocean, "profile");
15715
6ae93518356c rgbplot.m. Match variable in docstring to function prototype.
Rik <rik@octave.org>
parents: 15714
diff changeset
83 %! subplot (1, 2, 2);
15713
168e380c8f18 rgbplot.m: create style option and add new composite style
Carnë Draug <carandraug+dev@gmail.com>
parents: 15518
diff changeset
84 %! rgbplot (ocean, "composite");
14271
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
85
15714
b1cd65881592 Clean up scripts in image directory.
Rik <rik@octave.org>
parents: 15713
diff changeset
86 %% Test input validation
14271
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
87 %!error rgbplot ()
e2a14d1b4eaa rgbplot.m: Add new Matlab compatible function for plotting colormaps
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
88 %!error rgbplot (1,2)
15714
b1cd65881592 Clean up scripts in image directory.
Rik <rik@octave.org>
parents: 15713
diff changeset
89 %!error <CMAP must be a valid colormap> rgbplot ({0 1 0})
16472
293f5479a7e7 rgbplot.m: Set the default style to "profile"
Rik <rik@octave.org>
parents: 15716
diff changeset
90 %!error <STYLE must be a string> rgbplot ([0 1 0], 2)
16766
7268845c0a1e avoid backquote in error messages, some uses in doc strings
John W. Eaton <jwe@octave.org>
parents: 16472
diff changeset
91 %!error <unknown style 'nostyle'> rgbplot ([0 1 0], "nostyle")
15714
b1cd65881592 Clean up scripts in image directory.
Rik <rik@octave.org>
parents: 15713
diff changeset
92