annotate scripts/plot/legend.m @ 10666:7a43499f074a

legend.m: Improve documentation string
author Rik <octave@nomad.inbox5.com>
date Wed, 26 May 2010 20:23:16 -0700
parents 3afcd24ced61
children 693e22af08ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8915
diff changeset
1 ## Copyright (C) 2001, 2006, 2007, 2008, 2009 Laurent Mazet
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
2 ## Copyright (C) 2006 John W. Eaton
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
3 ##
6440
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
4 ## This file is part of Octave.
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
5 ##
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
7 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
9 ## your option) any later version.
6440
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
10 ##
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6395
diff changeset
14 ## General Public License for more details.
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
15 ##
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
18 ## <http://www.gnu.org/licenses/>.
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
19
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
21 ## @deftypefn {Function File} {} legend (@var{str1}, @var{str2}, @dots{})
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
22 ## @deftypefnx {Function File} {} legend (@var{matstr})
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
23 ## @deftypefnx {Function File} {} legend (@var{cell})
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
24 ## @deftypefnx {Function File} {} legend (@dots{}, "location", @var{pos})
10662
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
25 ## @deftypefnx {Function File} {} legend (@var{hax}, @dots{})
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
26 ## @deftypefnx {Function File} {} legend (@var{hobjs}, @dots{})
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
27 ## @deftypefnx {Function File} {} legend (@var{hax}, @var{hobjs}, @dots{})
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
28 ## @deftypefnx {Function File} {} legend ("@var{option}")
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
29 ##
10662
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
30 ## Display a legend for the axes with handle @var{hax}, or the current axes,
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
31 ## using the specified strings as labels. Legend entries may be specified
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
32 ## as individual character string arguments, a character array, or a cell
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
33 ## array of character strings. If the handles, @var{hobjs}, are not specified
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
34 ## then the legend's strings will be associated with the axes' descendants.
10662
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
35 ## Legend works on line graphs, bar graphs, etc.
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
36 ## A plot must exist before legend is called.
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
37 ##
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6740
diff changeset
38 ## The optional parameter @var{pos} specifies the location of the legend
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6740
diff changeset
39 ## as follows:
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
40 ##
6977
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
41 ## @multitable @columnfractions 0.06 0.14 0.80
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
42 ## @item @tab north @tab
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
43 ## center top
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
44 ## @item @tab south @tab
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
45 ## center bottom
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
46 ## @item @tab east @tab
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
47 ## right center
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
48 ## @item @tab west @tab
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
49 ## left center
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
50 ## @item @tab northeast @tab
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
51 ## right top (default)
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
52 ## @item @tab northwest @tab
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
53 ## left top
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
54 ## @item @tab southeast @tab
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
55 ## right bottom
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
56 ## @item @tab southwest @tab
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
57 ## left bottom
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
58 ## @item
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
59 ## @item @tab outside @tab
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
60 ## can be appended to any location string
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
61 ## @end multitable
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
62 ##
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
63 ## The following customizations are available using @var{option}:
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
64 ##
7148
735086cfd405 [project @ 2007-11-09 18:01:44 by jwe]
jwe
parents: 7054
diff changeset
65 ## @table @asis
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6740
diff changeset
66 ## @item "show"
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
67 ## Show legend on the plot
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6740
diff changeset
68 ## @item "hide"
7148
735086cfd405 [project @ 2007-11-09 18:01:44 by jwe]
jwe
parents: 7054
diff changeset
69 ## @itemx "off"
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
70 ## Hide legend on the plot
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6740
diff changeset
71 ## @item "boxon"
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
72 ## Show a box around legend
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6740
diff changeset
73 ## @item "boxoff"
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
74 ## Hide the box around legend
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6740
diff changeset
75 ## @item "left"
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
76 ## Place text to the left of the keys
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6740
diff changeset
77 ## @item "right"
10666
7a43499f074a legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents: 10662
diff changeset
78 ## Place text to the right of the keys
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
79 ## @end table
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
80 ## @end deftypefn
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
81
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
82 function legend (varargin)
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
83
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8190
diff changeset
84 [ca, varargin, nargin] = __plt_get_axis_arg__ ("legend", varargin{:});
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6163
diff changeset
85 nargs = nargin;
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
86
10662
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
87 if (all (ishandle (varargin{1})))
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
88 kids = flipud (varargin{1}(:));
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
89 varargin(1) = [];
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
90 nargs = numel (varargin);
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
91 else
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
92 kids = get (ca, "children");
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
93 endif
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
94 nkids = numel (kids);
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
95
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
96 if (nargs > 0)
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
97 pos = varargin{nargs};
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
98 if (isnumeric (pos) && isscalar (pos) && round (pos) == pos)
6395
a8dd70bacc1e [project @ 2007-03-07 22:22:12 by jwe]
jwe
parents: 6272
diff changeset
99 if (pos >= -1 && pos <= 4)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
100 set (ca, "keypos", pos);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
101 nargs--;
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
102 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
103 error ("legend: invalid position specified");
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
104 endif
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
105 endif
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
106 endif
6977
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
107
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
108 if (nargs > 1)
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
109 pos = varargin{nargs-1};
7054
1c5b2b5b58ba [project @ 2007-10-23 23:22:16 by jwe]
jwe
parents: 7017
diff changeset
110 str = varargin{nargs};
6977
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
111 if (strcmpi (pos, "location") && ischar (str))
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
112 set (ca, "keypos", str);
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
113 nargs -= 2;
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
114 endif
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
115 endif
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
116
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6163
diff changeset
117 k = 1;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6163
diff changeset
118 turn_on_legend = false;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6163
diff changeset
119
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
120 if (nargs == 1)
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
121 arg = varargin{1};
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
122 if (ischar (arg))
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
123 if (rows (arg) == 1)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
124 str = tolower (deblank (arg));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
125 switch (str)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
126 case {"off", "hide"}
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
127 set (ca, "key", "off");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
128 nargs--;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
129 case "show"
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
130 set (ca, "key", "on");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
131 nargs--;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
132 case "toggle"
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
133 val = get (ca, "key");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
134 if (strcmpi (val, "on"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
135 set (ca, "key", "off");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
136 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
137 set (ca, "key", "on");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
138 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
139 nargs--;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
140 case "boxon"
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
141 set (ca, "key", "on", "keybox", "on");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
142 nargs--;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
143 case "boxoff"
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
144 set (ca, "keybox", "off");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
145 nargs--;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
146 case "left"
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
147 set (ca, "keyreverse", "off")
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
148 nargs--;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
149 case "right"
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
150 set (ca, "keyreverse", "on")
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
151 nargs--;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
152 otherwise
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
153 endswitch
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
154 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
155 varargin = cellstr (arg);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
156 nargs = numel (varargin);
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
157 endif
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
158 elseif (iscellstr (arg))
8529
774b44619c5c Fix legend order for both horizontal and vertical string cell.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 8343
diff changeset
159 varargin = arg;
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
160 nargs = numel (varargin);
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
161 else
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
162 error ("legend: expecting argument to be a character string");
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
163 endif
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
164 endif
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
165
6272
a1f3d3b7ee5c [project @ 2007-02-06 02:09:48 by jwe]
jwe
parents: 6257
diff changeset
166 if (nargs > 0)
a1f3d3b7ee5c [project @ 2007-02-06 02:09:48 by jwe]
jwe
parents: 6257
diff changeset
167 have_data = false;
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
168 for k = 1:nkids
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
169 typ = get (kids(k), "type");
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
170 if (strcmp (typ, "line") || strcmp (typ, "surface")
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
171 || strcmp (typ, "patch") || strcmp (typ, "hggroup"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
172 have_data = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
173 break;
6272
a1f3d3b7ee5c [project @ 2007-02-06 02:09:48 by jwe]
jwe
parents: 6257
diff changeset
174 endif
a1f3d3b7ee5c [project @ 2007-02-06 02:09:48 by jwe]
jwe
parents: 6257
diff changeset
175 endfor
a1f3d3b7ee5c [project @ 2007-02-06 02:09:48 by jwe]
jwe
parents: 6257
diff changeset
176 if (! have_data)
a1f3d3b7ee5c [project @ 2007-02-06 02:09:48 by jwe]
jwe
parents: 6257
diff changeset
177 warning ("legend: plot data is empty; setting key labels has no effect");
a1f3d3b7ee5c [project @ 2007-02-06 02:09:48 by jwe]
jwe
parents: 6257
diff changeset
178 endif
6147
e14b0e9b7bf7 [project @ 2006-11-09 03:28:01 by jwe]
jwe
parents: 6146
diff changeset
179 endif
e14b0e9b7bf7 [project @ 2006-11-09 03:28:01 by jwe]
jwe
parents: 6146
diff changeset
180
6575
9ef0450c873d [project @ 2007-04-25 14:07:20 by jwe]
jwe
parents: 6450
diff changeset
181 warned = false;
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
182 k = nkids;
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
183 for i = 1:nargs
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
184 arg = varargin{i};
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
185 if (ischar (arg))
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
186 typ = get (kids(k), "type");
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
187 while (k > 1
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
188 && ! (strcmp (typ, "line") || strcmp (typ, "surface")
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
189 || strcmp (typ, "patch") || strcmp (typ, "hggroup")))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
190 typ = get (kids(--k), "type");
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6163
diff changeset
191 endwhile
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
192 if (k > 0)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
193 if (strcmp (get (kids(k), "type"), "hggroup"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
194 hgkids = get (kids(k), "children");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
195 for j = 1 : length (hgkids)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
196 hgobj = get (hgkids (j));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
197 if (isfield (hgobj, "keylabel"))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
198 set (hgkids(j), "keylabel", arg);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
199 break;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
200 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
201 endfor
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
202 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
203 set (kids(k), "keylabel", arg);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
204 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
205 turn_on_legend = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
206 if (--k == 0)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
207 break;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
208 endif
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6163
diff changeset
209 elseif (! warned)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
210 warned = true;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9457
diff changeset
211 warning ("legend: ignoring extra labels");
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6163
diff changeset
212 endif
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
213 else
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
214 error ("legend: expecting argument to be a character string");
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
215 endif
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
216 endfor
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
217
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6163
diff changeset
218 if (turn_on_legend)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6163
diff changeset
219 set (ca, "key", "on");
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
220 endif
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
221
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
222 endfunction
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
223
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
224 %!demo
8790
a013ff655ca4 Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
225 %! clf
8343
9f34f7636fe0 legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents: 8291
diff changeset
226 %! plot(1:10, 1:10, 1:10, fliplr(1:10));
9f34f7636fe0 legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents: 8291
diff changeset
227 %! title("incline is blue and decline is green");
9f34f7636fe0 legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents: 8291
diff changeset
228 %! legend({"I'm blue", "I'm green"}, "location", "east")
9f34f7636fe0 legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents: 8291
diff changeset
229
9f34f7636fe0 legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents: 8291
diff changeset
230 %!demo
8790
a013ff655ca4 Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
231 %! clf
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
232 %! plot(1:10, 1:10, 1:10, fliplr(1:10));
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
233 %! title("incline is blue and decline is green");
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
234 %! legend("I'm blue", "I'm green", "location", "east")
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
235
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
236 %!demo
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
237 %! clf
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
238 %! plot(1:10, 1:10);
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
239 %! title("a very long label can sometimes cause problems");
6977
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
240 %! legend({"hello world"}, "location", "northeastoutside")
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
241
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
242 %!demo
8790
a013ff655ca4 Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
243 %! clf
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
244 %! plot(1:10, 1:10);
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
245 %! title("a very long label can sometimes cause problems");
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
246 %! legend("hello world", "location", "northeastoutside")
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
247
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
248 %!demo
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
249 %! clf
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
250 %! labels = {};
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
251 %! for i = 1:5
8915
485eabc0cfec __go_draw_axes__.m: Preserve the order of axes' children when pruning the handles for the {x,y,z}labels and title.
Ben Abbott <bpabbott@mac.com>
parents: 8790
diff changeset
252 %! h = plot(1:100, i + rand(100,1)); hold on;
485eabc0cfec __go_draw_axes__.m: Preserve the order of axes' children when pruning the handles for the {x,y,z}labels and title.
Ben Abbott <bpabbott@mac.com>
parents: 8790
diff changeset
253 %! set (h, "color", get (gca, "colororder")(i,:))
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7148
diff changeset
254 %! labels = {labels{:}, cstrcat("Signal ", num2str(i))};
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
255 %! endfor; hold off;
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
256 %! title("Signals with random offset and uniform noise")
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
257 %! xlabel("Sample Nr [k]"); ylabel("Amplitude [V]");
6977
e78e31f0a236 [project @ 2007-10-08 19:09:32 by jwe]
jwe
parents: 6895
diff changeset
258 %! legend(labels, "location", "southoutside")
6146
1a6d826e92b5 [project @ 2006-11-09 03:13:11 by jwe]
jwe
parents:
diff changeset
259 %! legend("boxon")
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
260
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
261 %!demo
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
262 %! clf
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
263 %! labels = {};
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
264 %! for i = 1:5
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
265 %! h = plot(1:100, i + rand(100,1)); hold on;
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
266 %! set (h, "color", get (gca, "colororder")(i,:))
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
267 %! labels = {labels{:}, cstrcat("Signal ", num2str(i))};
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
268 %! endfor; hold off;
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
269 %! title("Signals with random offset and uniform noise")
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
270 %! xlabel("Sample Nr [k]"); ylabel("Amplitude [V]");
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
271 %! legend(labels{:}, "location", "southoutside")
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
272 %! legend("boxon")
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
273
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
274 %!demo
9457
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
275 %! clf
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
276 %! x = linspace (0, 10);
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
277 %! plot (x, x);
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
278 %! hold ("on");
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
279 %! stem (x, x.^2, 'g')
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
280 %! legend ("linear");
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
281 %! hold ("off");
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
282
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
283 %!demo
9457
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
284 %! clf
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
285 %! x = linspace (0, 10);
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
286 %! plot (x, x, x, x.^2);
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
287 %! legend ("linear");
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
288
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
289 %!demo
9457
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
290 %! clf
9451
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
291 %! x = linspace (0, 10);
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
292 %! plot (x, x, x, x.^2);
350148cc0774 legend.m: fix legend order
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
293 %! legend ("linear", "quadratic");
9457
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
294
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
295 %!demo
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
296 %! clf
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
297 %! bar (rand (2, 3))
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
298 %! ylim ([0 1.2])
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
299 %! legend ({"1st Bar", "2nd Bar", "3rd Bar"})
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
300
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
301 %!demo
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
302 %! clf
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
303 %! bar (rand (2, 3))
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
304 %! ylim ([0 1.2])
f9fb8c1a8e45 legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents: 9451
diff changeset
305 %! legend ("1st Bar", "2nd Bar", "3rd Bar")
10662
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
306
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
307 %!demo
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
308 %! clf
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
309 %! x = 0:0.1:7;
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
310 %! h = plot (x, sin(x), x, cos(x), x, sin(x.^2/10), x, cos(x.^2/10));
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
311 %! title ("Only the sin() objects have keylabels")
3afcd24ced61 legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents: 10549
diff changeset
312 %! legend (h([1, 3]), {"sin(x)", "sin(x^2/10)"}, "location", "southwest")