Mercurial > hg > octave-nkf
annotate scripts/plot/appearance/legend.m @ 18899:adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
* legend.m: Don't create legend for 'boxon', 'boxoff', 'hide', and null input.
Do create legend if just a location or orientation is passed in.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 06 May 2014 19:57:44 -0700 |
parents | ce36233e4849 |
children | 5f37573a6868 |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17730
diff
changeset
|
1 ## Copyright (C) 2010-2013 David Bateman |
6146 | 2 ## |
6440 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6440 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
6146 | 14 ## |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6146 | 18 |
19 ## -*- texinfo -*- | |
10666
7a43499f074a
legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents:
10662
diff
changeset
|
20 ## @deftypefn {Function File} {} legend (@var{str1}, @var{str2}, @dots{}) |
6146 | 21 ## @deftypefnx {Function File} {} legend (@var{matstr}) |
14755
bf759828760c
doc: Clarify input must be cellstr, not just cell, to legend().
Rik <octave@nomad.inbox5.com>
parents:
14747
diff
changeset
|
22 ## @deftypefnx {Function File} {} legend (@var{cellstr}) |
10666
7a43499f074a
legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents:
10662
diff
changeset
|
23 ## @deftypefnx {Function File} {} legend (@dots{}, "location", @var{pos}) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
24 ## @deftypefnx {Function File} {} legend (@dots{}, "orientation", @var{orient}) |
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}") |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
29 ## @deftypefnx {Function File} {[@var{hleg}, @var{hleg_obj}, @var{hplot}, @var{labels}] =} legend (@dots{}) |
6146 | 30 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
31 ## Display a legend for the current axes using the specified strings as labels. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
32 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
33 ## Legend entries may be specified as individual character string arguments, |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
34 ## a character array, or a cell array of character strings. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
35 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
36 ## If the first argument @var{hax} is an axes handle, then plot into this axis, |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
37 ## rather than the current axes returned by @code{gca}. If the handles, |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
38 ## @var{hobjs}, are not specified then the legend's strings will be associated |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
39 ## with the axes' descendants. @code{legend} works on line graphs, |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
40 ## bar graphs, etc. A plot must exist before legend is called. |
6146 | 41 ## |
6895 | 42 ## The optional parameter @var{pos} specifies the location of the legend |
43 ## as follows: | |
6146 | 44 ## |
6977 | 45 ## @multitable @columnfractions 0.06 0.14 0.80 |
17204
d87179b38bcf
doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
46 ## @headitem @tab pos @tab location of the legend |
d87179b38bcf
doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
47 ## @item @tab north @tab center top |
d87179b38bcf
doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
48 ## @item @tab south @tab center bottom |
d87179b38bcf
doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
49 ## @item @tab east @tab right center |
d87179b38bcf
doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
50 ## @item @tab west @tab left center |
d87179b38bcf
doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
51 ## @item @tab northeast @tab right top (default) |
d87179b38bcf
doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
52 ## @item @tab northwest @tab left top |
d87179b38bcf
doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
53 ## @item @tab southeast @tab right bottom |
d87179b38bcf
doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
54 ## @item @tab southwest @tab left bottom |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
55 ## @item |
17204
d87179b38bcf
doc: Touch up alignment of @multitables in plot, legend, newplot.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
56 ## @item @tab outside @tab can be appended to any location string |
6146 | 57 ## @end multitable |
58 ## | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
59 ## The optional parameter @var{orient} determines if the key elements |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
60 ## are placed vertically or horizontally. The allowed values are |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
61 ## @qcode{"vertical"} (default) or @qcode{"horizontal"}. |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
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 | 64 ## |
7148 | 65 ## @table @asis |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
66 ## @item @qcode{"show"} |
10666
7a43499f074a
legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents:
10662
diff
changeset
|
67 ## Show legend on the plot |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10666
diff
changeset
|
68 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
69 ## @item @qcode{"hide"} |
10666
7a43499f074a
legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents:
10662
diff
changeset
|
70 ## Hide legend on the plot |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10666
diff
changeset
|
71 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
72 ## @item @qcode{"toggle"} |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
73 ## Toggles between @qcode{"hide"} and @qcode{"show"} |
12394
c2e1973d870b
legend.m: "legend off" should delete the legend object.
Ben Abbott <bpabbott@mac.com>
parents:
12388
diff
changeset
|
74 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
75 ## @item @qcode{"boxon"} |
17532
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
76 ## Show a box around legend (default) |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10666
diff
changeset
|
77 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
78 ## @item @qcode{"boxoff"} |
10666
7a43499f074a
legend.m: Improve documentation string
Rik <octave@nomad.inbox5.com>
parents:
10662
diff
changeset
|
79 ## Hide the box around legend |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10666
diff
changeset
|
80 ## |
17532
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
81 ## @item @qcode{"right"} |
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
82 ## Place label text to the right of the keys (default) |
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
83 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
84 ## @item @qcode{"left"} |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
85 ## Place label text to the left of the keys |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10666
diff
changeset
|
86 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
87 ## @item @qcode{"off"} |
12394
c2e1973d870b
legend.m: "legend off" should delete the legend object.
Ben Abbott <bpabbott@mac.com>
parents:
12388
diff
changeset
|
88 ## Delete the legend object |
6146 | 89 ## @end table |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
90 ## |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
91 ## The optional output values are |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
92 ## |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
93 ## @table @var |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
94 ## @item hleg |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
95 ## The graphics handle of the legend object. |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
96 ## |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
97 ## @item hleg_obj |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
98 ## Graphics handles to the text and line objects which make up the legend. |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
99 ## |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
100 ## @item hplot |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
101 ## Graphics handles to the plot objects which were used in making the legend. |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
102 ## |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
103 ## @item labels |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
104 ## A cell array of strings of the labels in the legend. |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
105 ## @end table |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
106 ## |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
107 ## The legend label text is either provided in the call to @code{legend} or |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
108 ## is taken from the DisplayName property of graphics objects. If no |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
109 ## labels or DisplayNames are available, then the label text is simply |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
110 ## @qcode{"data1"}, @qcode{"data2"}, @dots{}, @nospell{@qcode{"dataN"}}. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
111 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17119
diff
changeset
|
112 ## Implementation Note: A legend is implemented as an additional axes object |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
113 ## of the current figure with the @qcode{"tag"} set to @qcode{"legend"}. |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
114 ## Properties of the legend object may be manipulated directly by using |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17204
diff
changeset
|
115 ## @code{set}. |
6146 | 116 ## @end deftypefn |
117 | |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
118 function [hleg, hleg_obj, hplot, labels] = legend (varargin) |
6146 | 119 |
11246
c463aed850b0
allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents:
11200
diff
changeset
|
120 if (nargin > 0 |
c463aed850b0
allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents:
11200
diff
changeset
|
121 && (! ishandle (varargin{1}) |
c463aed850b0
allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents:
11200
diff
changeset
|
122 || (strcmp (get (varargin{1}, "type"), "axes") |
c463aed850b0
allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents:
11200
diff
changeset
|
123 && ! strcmp (get (varargin{1}, "tag"), "legend")))) |
17065
991e8a386aa3
legend.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16973
diff
changeset
|
124 [ca, varargin, nargin] = __plt_get_axis_arg__ ("legend", varargin{:}); |
991e8a386aa3
legend.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16973
diff
changeset
|
125 if (isempty (ca)) |
991e8a386aa3
legend.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16973
diff
changeset
|
126 ca = gca (); |
991e8a386aa3
legend.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
16973
diff
changeset
|
127 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
128 fig = get (ca, "parent"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
129 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
130 fig = get (0, "currentfigure"); |
11246
c463aed850b0
allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents:
11200
diff
changeset
|
131 if (isempty (fig)) |
c463aed850b0
allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents:
11200
diff
changeset
|
132 fig = gcf (); |
c463aed850b0
allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents:
11200
diff
changeset
|
133 endif |
c463aed850b0
allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents:
11200
diff
changeset
|
134 ca = gca (); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
135 endif |
6146 | 136 |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
137 ## Special handling for plotyy which has two axes objects |
13216 | 138 if (ishandle (ca) && isprop (ca, "__plotyy_axes__")) |
139 plty = get (ca, "__plotyy_axes__"); | |
140 if (isscalar (plty) && ishandle (plty)) | |
11199
91c606a68693
minor fix to previous changeset
David Bateman <dbateman@free.fr>
parents:
11198
diff
changeset
|
141 ca = [ca, plty]; |
13216 | 142 elseif (iscell (plty)) |
11199
91c606a68693
minor fix to previous changeset
David Bateman <dbateman@free.fr>
parents:
11198
diff
changeset
|
143 ca = [ca, plty{:}]; |
13216 | 144 elseif (all (ishandle (plty))) |
145 ca = [ca, plty(:).']; | |
146 else | |
15202
f3b5cadfd6d5
fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents:
14868
diff
changeset
|
147 error ("legend.m: This should not happen. File a bug report."); |
11199
91c606a68693
minor fix to previous changeset
David Bateman <dbateman@free.fr>
parents:
11198
diff
changeset
|
148 endif |
13216 | 149 ## Remove duplicates while preserving order |
150 [~, n] = unique (ca); | |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
151 ca = ca(sort (n)); |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
152 endif |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
153 |
11246
c463aed850b0
allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents:
11200
diff
changeset
|
154 if (nargin > 0 && all (ishandle (varargin{1}))) |
10662
3afcd24ced61
legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
155 kids = flipud (varargin{1}(:)); |
3afcd24ced61
legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
156 varargin(1) = []; |
3afcd24ced61
legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
157 else |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
158 kids = ca; |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
159 kids(strcmp (get (ca, "tag"), "legend")) = []; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
160 if (isscalar (kids)) |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
161 kids = get (kids, "children")(:); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
162 else |
17677
c14e5af64de4
legend.m: Fix invalid legend handle with plotyy (bug #35321).
Rik <rik@octave.org>
parents:
17572
diff
changeset
|
163 kids = flipud (vertcat (get (kids, "children"){:})); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
164 endif |
10662
3afcd24ced61
legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
165 endif |
11246
c463aed850b0
allow legend and gcf to work when no figure is present
John W. Eaton <jwe@octave.org>
parents:
11200
diff
changeset
|
166 nargs = numel (varargin); |
10662
3afcd24ced61
legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
167 nkids = numel (kids); |
3afcd24ced61
legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
168 |
18899
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
169 ## Find any existing legend object on figure |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
170 hlegend = []; |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
171 fkids = get (fig, "children"); |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
172 for i = 1 : numel (fkids) |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
173 if ( strcmp (get (fkids(i), "type"), "axes") |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
174 && strcmp (get (fkids(i), "tag"), "legend")) |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
175 udata = get (fkids(i), "userdata"); |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
176 if (any (udata.handle == ca)) |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
177 hlegend = fkids(i); |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
178 break; |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
179 endif |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
180 endif |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
181 endfor |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
182 |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
183 orientation = "default"; |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
184 location = "default"; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
185 show = "create"; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
186 textpos = "default"; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
187 box = "default"; |
18899
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
188 delete_leg = false; |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
189 find_leg_hdl = (nargs == 0); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
190 |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
191 ## Process old way of specifying location with a number rather than a string. |
6146 | 192 if (nargs > 0) |
193 pos = varargin{nargs}; | |
13279
984359717d71
Use common code idiom for checking whether a double value is an integer.
Rik <octave@nomad.inbox5.com>
parents:
13216
diff
changeset
|
194 if (isnumeric (pos) && isscalar (pos) && pos == fix (pos)) |
6395 | 195 if (pos >= -1 && pos <= 4) |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
196 location = [{"northeastoutside", "best", "northeast", |
11003
b1cfff739af5
legend.m: Index location cellstr to obtain a string.
Ben Abbott <bpabbott@mac.com>
parents:
10999
diff
changeset
|
197 "northwest", "southwest", "southeast"}] {pos + 2}; |
10549 | 198 nargs--; |
6146 | 199 else |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
200 error ("legend: invalid location specified"); |
6146 | 201 endif |
202 endif | |
203 endif | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
204 |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
205 ## Find location and orientation property/value pairs |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
206 while (nargs > 1) |
6977 | 207 pos = varargin{nargs-1}; |
7054 | 208 str = varargin{nargs}; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
209 if (strcmpi (pos, "location") && ischar (str)) |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
210 location = lower (str); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
211 nargs -= 2; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
212 elseif (strcmpi (pos, "orientation") && ischar (str)) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
213 orientation = lower (str); |
10989
6ea65c5de87a
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10949
diff
changeset
|
214 nargs -= 2; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
215 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
216 break; |
6977 | 217 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
218 endwhile |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
219 |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
220 ## Validate the orientation |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
221 switch (orientation) |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
222 case {"vertical", "horizontal", "default"} |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
223 ## These are all accepted orientations. |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
224 otherwise |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
225 error ("legend: unrecognized legend orientation"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
226 endswitch |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
227 |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
228 ## Validate the location type |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
229 outside = false; |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
230 inout = strfind (location, "outside"); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
231 if (! isempty (inout)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
232 outside = true; |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
233 location = location(1:inout-1); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
234 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
235 outside = false; |
6977 | 236 endif |
6146 | 237 |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
238 switch (location) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
239 case {"north", "south", "east", "west", "northeast", "northwest", ... |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
240 "southeast", "southwest", "default"} |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
241 case "best" |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
242 warning ("legend: 'best' not yet implemented for location specifier\n"); |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
243 location = "northeast"; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
244 otherwise |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
245 error ("legend: unrecognized legend location"); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
246 endswitch |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
247 |
6146 | 248 if (nargs == 1) |
249 arg = varargin{1}; | |
250 if (ischar (arg)) | |
251 if (rows (arg) == 1) | |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
252 str = tolower (strtrim (arg)); |
10549 | 253 switch (str) |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
254 case "off" |
18899
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
255 delete_leg = true; |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
256 case "hide" |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
257 show = "off"; |
10549 | 258 nargs--; |
259 case "show" | |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
260 if (! isempty (hlegend)) |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
261 show = "on"; |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
262 else |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
263 show = "create"; |
17532
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
264 textpos = "right"; |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
265 endif |
10549 | 266 nargs--; |
267 case "toggle" | |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
268 if (isempty (hlegend)) |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
269 show = "create"; |
17532
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
270 textpos = "right"; |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
271 elseif (strcmp (get (hlegend, "visible"), "off")) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
272 show = "on"; |
10549 | 273 else |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
274 show = "off"; |
10549 | 275 endif |
276 nargs--; | |
277 case "boxon" | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
278 box = "on"; |
10549 | 279 nargs--; |
280 case "boxoff" | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
281 box = "off"; |
10549 | 282 nargs--; |
283 case "left" | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
284 textpos = "left"; |
10549 | 285 nargs--; |
286 case "right" | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
287 textpos = "right"; |
10549 | 288 nargs--; |
289 endswitch | |
6146 | 290 else |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
291 ## Character matrix of labels |
10549 | 292 varargin = cellstr (arg); |
293 nargs = numel (varargin); | |
6146 | 294 endif |
295 elseif (iscellstr (arg)) | |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
296 ## Cell array of labels |
8529
774b44619c5c
Fix legend order for both horizontal and vertical string cell.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
8343
diff
changeset
|
297 varargin = arg; |
6146 | 298 nargs = numel (varargin); |
299 else | |
300 error ("legend: expecting argument to be a character string"); | |
301 endif | |
14589
fd6e50e2eee6
legend() should accept labels being specified as both cellstrs and char.
Ben Abbott <bpabbott@mac.com>
parents:
14585
diff
changeset
|
302 elseif (nargs > 1 && iscellstr (varargin{1})) |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
303 ## Cell array of labels followed by property/value pairs |
14589
fd6e50e2eee6
legend() should accept labels being specified as both cellstrs and char.
Ben Abbott <bpabbott@mac.com>
parents:
14585
diff
changeset
|
304 varargin = {varargin{1}{:}, varargin{2:end}}; |
fd6e50e2eee6
legend() should accept labels being specified as both cellstrs and char.
Ben Abbott <bpabbott@mac.com>
parents:
14585
diff
changeset
|
305 nargs = numel (varargin); |
6146 | 306 endif |
307 | |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
308 have_labels = (nargs > 0); |
18899
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
309 hobjects = []; |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
310 hplots = []; |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
311 text_strings = {}; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
312 |
18899
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
313 if (delete_leg) |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
314 delete (hlegend); |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
315 hlegend = []; |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
316 elseif (find_leg_hdl) |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
317 ## Don't change anything about legend. |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
318 ## hleg output will be assigned hlegend value at end of function. |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
319 elseif (strcmp (show, "off")) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
320 if (! isempty (hlegend)) |
14578
f579a94aacaa
Preserve legend handle when changing properties (Bug # 36259).
Carnë Draug <carandraug+dev@gmail.com>
parents:
14552
diff
changeset
|
321 set (findobj (hlegend), "visible", "off"); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
322 hlegend = []; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
323 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
324 elseif (strcmp (show, "on")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
325 if (! isempty (hlegend)) |
14578
f579a94aacaa
Preserve legend handle when changing properties (Bug # 36259).
Carnë Draug <carandraug+dev@gmail.com>
parents:
14552
diff
changeset
|
326 set (findobj (hlegend), "visible", "on"); |
18899
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
327 ## NOTE: Matlab sets both "visible" and "box" to "on" |
14585
c38a253723d3
Syncrhonize legend's "visible" and "box" properties. (Bug # 36136)
Ben Abbott <bpabbott@mac.com>
parents:
14581
diff
changeset
|
328 set (hlegend, "visible", get (hlegend, "box")); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
329 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
330 elseif (strcmp (box, "on")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
331 if (! isempty (hlegend)) |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
332 set (hlegend, "box", "on", "visible", "on"); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
333 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
334 elseif (strcmp (box, "off")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
335 if (! isempty (hlegend)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
336 set (hlegend, "box", "off", "visible", "off"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
337 endif |
18899
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
338 elseif (! have_labels && ! isempty (hlegend) |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
339 && ! (strcmp (location, "default") && strcmp (orientation, "default"))) |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
340 ## Changing location or orientation of existing legend |
18899
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
341 if (strcmp (location, "default")) |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
342 set (hlegend, "orientation", orientation); |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
343 elseif (strcmp (orientation, "default")) |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
344 if (outside) |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
345 set (hlegend, "location", [location "outside"]); |
12398
735e43b75e45
Allow the legend location and orientation to be set without modifying the legend keys (#32374)
David Bateman <dbateman@free.fr>
parents:
12396
diff
changeset
|
346 else |
18899
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
347 set (hlegend, "location", location); |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
348 endif |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
349 else |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
350 if (outside) |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
351 set (hlegend, "location", [location "outside"], |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
352 "orientation", orientation); |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
353 else |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
354 set (hlegend, "location", location, |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
355 "orientation", orientation); |
12398
735e43b75e45
Allow the legend location and orientation to be set without modifying the legend keys (#32374)
David Bateman <dbateman@free.fr>
parents:
12396
diff
changeset
|
356 endif |
735e43b75e45
Allow the legend location and orientation to be set without modifying the legend keys (#32374)
David Bateman <dbateman@free.fr>
parents:
12396
diff
changeset
|
357 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
358 else |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
359 ## Create new legend |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
360 hobjects = []; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
361 hplots = []; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
362 text_strings = {}; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
363 |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
364 if (have_labels) |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
365 ## Check for valid data that can be labeled. |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
366 have_data = false; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
367 have_dname = false; |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
368 for k = 1 : nkids |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
369 typ = get (kids(k), "type"); |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
370 if (any (strcmp (typ, {"line", "patch", "surface", "hggroup"}))) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
371 have_data = true; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
372 break; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
373 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
374 endfor |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
375 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
376 if (! have_data) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
377 warning ("legend: plot data is empty; setting key labels has no effect"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
378 endif |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
379 else |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
380 ## No labels. Search for DisplayName property. |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
381 have_dname = false; |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
382 for k = 1 : nkids |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
383 hkid = kids(k); |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
384 typ = get (hkid, "type"); |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
385 if (any (strcmp (typ, {"line", "patch", "surface"}))) |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
386 if (! isempty (get (hkid, "displayname"))) |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
387 have_dname = true; |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
388 break; |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
389 endif |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
390 elseif (strcmp (typ, "hggroup")) |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
391 hgkids = get (hkid, "children"); |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
392 for j = 1 : length (hgkids) |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
393 try |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
394 dname = get (hgkids(j), "DisplayName"); |
17538
b29c8a067c11
legend.m: Remove leftover code bits from debugging.
Rik <rik@octave.org>
parents:
17537
diff
changeset
|
395 if (! isempty (dname)) |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
396 have_dname = true; |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
397 break; # break from j-loop over hgkids |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
398 endif |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
399 end_try_catch |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
400 endfor |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
401 if (have_dname) |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
402 break; # break from k loop over nkids |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
403 endif |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
404 endif # elseif hggroup |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
405 endfor # for loop k = 1 : nkids |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
406 endif # else branch of if (have_labels) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
407 |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
408 if (have_labels || ! have_dname) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
409 k = nkids; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
410 if (! have_labels) |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
411 varargin = arrayfun (@(x) sprintf ("data%d", x), [1:nkids]', |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
412 "uniformoutput", false); |
16795
38c1a421f082
When no keys are specified and defaults are populated, set have_labels = true.
Ben Abbott <bpabbott@mac.com>
parents:
16728
diff
changeset
|
413 have_labels = true; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
414 nargs = nkids; |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
415 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
416 for i = 1 : nargs |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
417 arg = varargin{i}; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
418 if (ischar (arg)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
419 typ = get (kids(k), "type"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
420 while (k > 0 |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
421 && ! any (strcmp (typ, {"line","patch","surface","hggroup"}))) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
422 typ = get (kids(--k), "type"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
423 endwhile |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
424 if (k > 0) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
425 if (strcmp (get (kids(k), "type"), "hggroup")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
426 hgkids = get (kids(k), "children"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
427 for j = 1 : length (hgkids) |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
428 hgobj = get (hgkids(j)); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
429 if (isfield (hgobj, "displayname")) |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
430 if (have_labels) |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
431 set (hgkids(j), "displayname", arg); |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
432 endif |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
433 hplots(end+1) = hgkids(j); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
434 text_strings(end+1) = arg; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
435 break; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
436 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
437 endfor |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
438 else |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
439 if (have_labels) |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
440 set (kids(k), "displayname", arg); |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
441 endif |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
442 hplots(end+1) = kids(k); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
443 text_strings(end+1) = arg; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
444 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
445 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
446 if (--k == 0) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
447 break; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
448 endif |
15441
e5a07d7aafcc
legend.m: Remove unused warning variable and associated code.
Rik <rik@octave.org>
parents:
15440
diff
changeset
|
449 else |
e5a07d7aafcc
legend.m: Remove unused warning variable and associated code.
Rik <rik@octave.org>
parents:
15440
diff
changeset
|
450 break; # k = 0, no further handles to process |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
451 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
452 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
453 error ("legend: expecting argument to be a character string"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
454 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
455 endfor |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
456 if (have_labels && i < nargs) |
13979
f35b593688a5
Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents:
13937
diff
changeset
|
457 warning ("legend: ignoring extra labels"); |
f35b593688a5
Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents:
13937
diff
changeset
|
458 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
459 else |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
460 ## No labels specified but objects have DisplayName property set. |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
461 k = nkids; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
462 while (k > 0) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
463 typ = get (kids(k), "type"); |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
464 while (k > 1 |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
465 && ! any (strcmp (typ, {"line","patch","surface","hggroup"}))) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
466 typ = get (kids(--k), "type"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
467 endwhile |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
468 if (! any (strcmp (typ, {"line","patch","surface","hggroup"}))) |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
469 break; |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
470 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
471 if (k > 0) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
472 if (strcmp (get (kids(k), "type"), "hggroup")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
473 hgkids = get (kids(k), "children"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
474 for j = 1 : length (hgkids) |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
475 hgobj = get (hgkids(j)); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
476 if (isfield (hgobj, "displayname") |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
477 && ! isempty (hgobj.displayname)) |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
478 hplots(end+1) = hgkids(j); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
479 text_strings(end+1) = hgobj.displayname; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
480 break; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
481 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
482 endfor |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
483 else |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
484 if (! isempty (get (kids(k), "displayname"))) |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
485 hplots(end+1) = kids(k); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
486 text_strings(end+1) = get (kids(k), "displayname"); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
487 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
488 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
489 if (--k == 0) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
490 break; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
491 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
492 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
493 endwhile |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
494 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
495 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
496 if (isempty (hplots)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
497 if (! isempty (hlegend)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
498 fkids = get (fig, "children"); |
16800
56102c33122d
Fix problems with changeset 286904321282.
Ben Abbott <bpabbott@mac.com>
parents:
16799
diff
changeset
|
499 delete (fkids(fkids == hlegend)); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
500 hlegend = []; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
501 hobjects = []; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
502 hplots = []; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
503 text_strings = {}; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
504 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
505 else |
14578
f579a94aacaa
Preserve legend handle when changing properties (Bug # 36259).
Carnë Draug <carandraug+dev@gmail.com>
parents:
14552
diff
changeset
|
506 ## Preserve the old legend if it exists |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
507 if (! isempty (hlegend)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
508 if (strcmp (textpos, "default")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
509 textpos = get (hlegend, "textposition"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
510 endif |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
511 if (strcmp (location, "default")) |
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
512 location = get (hlegend, "location"); |
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
513 inout = strfind (location, "outside"); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
514 if (! isempty (inout)) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
515 outside = true; |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
516 location = location(1:inout-1); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
517 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
518 outside = false; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
519 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
520 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
521 if (strcmp (orientation, "default")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
522 orientation = get (hlegend, "orientation"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
523 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
524 box = get (hlegend, "box"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
525 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
526 if (strcmp (textpos, "default")) |
17532
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
527 textpos = "right"; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
528 endif |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
529 if (strcmp (location, "default")) |
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
530 location = "northeast"; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
531 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
532 if (strcmp (orientation, "default")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
533 orientation = "vertical"; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
534 endif |
14529
aabdc8f281f1
legend.m: Change default to boxon for Matlab compatibility (bug #36105).
Rik <octave@nomad.inbox5.com>
parents:
14375
diff
changeset
|
535 box = "on"; |
6272 | 536 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
537 |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
538 ## Get axis size and fontsize in points. |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
539 ## Rely on listener to handle coversion. |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
540 units = get (ca(1), "units"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
541 unwind_protect |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
542 set (ca(1), "units", "points"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
543 set (ca(1), "fontunits", "points"); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
544 if (isempty (hlegend) || ! isprop (hlegend, "unmodified_axes_position")) |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
545 unmodified_axes_position = get (ca(1), "position"); |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
546 unmodified_axes_outerposition = get (ca(1), "outerposition"); |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
547 else |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
548 unmodified_axes_position = get (hlegend, "unmodified_axes_position"); |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
549 unmodified_axes_outerposition = get (hlegend, ... |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
550 "unmodified_axes_outerposition"); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
551 endif |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
552 ca_pos = unmodified_axes_position; |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
553 ca_outpos = unmodified_axes_outerposition; |
16910
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
554 tightinset = get (ca(1), "tightinset"); |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
555 for i = 2 : numel (ca) |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
556 tightinset = max (tightinset, get (ca(i), "tightinset")); |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
557 endfor |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
558 unwind_protect_cleanup |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
559 set (ca(1), "units", units); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
560 end_unwind_protect |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
561 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
562 ## Padding between legend entries horizontally and vertically |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
563 xpad = 2; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
564 ypad = 2; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
565 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
566 linelength = 15; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
567 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
568 ## Create the axis first |
18802
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
569 oldfig = get (0, "currentfigure"); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
570 if (oldfig != fig) |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
571 set (0, "currentfigure", fig); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
572 else |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
573 oldfig = []; |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
574 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
575 curaxes = get (fig, "currentaxes"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
576 unwind_protect |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
577 ud = ancestor (hplots, "axes"); |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
578 if (! isscalar (ud)) |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
579 ud = unique ([ud{:}]); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
580 endif |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
581 if (isempty (hlegend)) |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
582 addprops = true; |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
583 hlegend = axes ("tag", "legend", "userdata", struct ("handle", ud), |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12437
diff
changeset
|
584 "box", box, |
14529
aabdc8f281f1
legend.m: Change default to boxon for Matlab compatibility (bug #36105).
Rik <octave@nomad.inbox5.com>
parents:
14375
diff
changeset
|
585 "xtick", [], "ytick", [], |
14578
f579a94aacaa
Preserve legend handle when changing properties (Bug # 36259).
Carnë Draug <carandraug+dev@gmail.com>
parents:
14552
diff
changeset
|
586 "xlim", [0, 1], "ylim", [0, 1], |
f579a94aacaa
Preserve legend handle when changing properties (Bug # 36259).
Carnë Draug <carandraug+dev@gmail.com>
parents:
14552
diff
changeset
|
587 "visible", ifelse (strcmp (box, "on"), "on", "off"), |
14746
3ddb62bd67c5
legend.m: Inherit font size from axes.
Konstantinos Poulios <logari81@gmail.com>
parents:
14589
diff
changeset
|
588 "activepositionproperty", "position", |
17534
ec105d91547e
legend.m: Inherit font properties from current axes. Default interpreter to 'tex'.
Rik <rik@octave.org>
parents:
17533
diff
changeset
|
589 "interpreter", "tex"); |
ec105d91547e
legend.m: Inherit font properties from current axes. Default interpreter to 'tex'.
Rik <rik@octave.org>
parents:
17533
diff
changeset
|
590 ## Inherit properties from current axis |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
591 ## "fontunits" shoud be first because it affects interpretation |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
592 ## of "fontsize" property |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
593 proplist = {"fontunits", "fontangle", "fontname", "fontsize", ... |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
594 "fontweight"}; |
17534
ec105d91547e
legend.m: Inherit font properties from current axes. Default interpreter to 'tex'.
Rik <rik@octave.org>
parents:
17533
diff
changeset
|
595 ca_props = get (ca(1), proplist); |
ec105d91547e
legend.m: Inherit font properties from current axes. Default interpreter to 'tex'.
Rik <rik@octave.org>
parents:
17533
diff
changeset
|
596 set (hlegend, proplist, ca_props); |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
597 else |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
598 addprops = false; |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
599 axes (hlegend); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
600 delete (get (hlegend, "children")); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
601 endif |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
602 if (addprops) |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
603 addproperty ("edgecolor", hlegend, "color", [0, 0, 0]); |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
604 addproperty ("textcolor", hlegend, "color", [0, 0, 0]); |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
605 locations = {"north", "south", "east", "west", ... |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
606 "{northeast}", "southeast", "northwest", "southwest", ... |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
607 "northoutside", "southoutside", ... |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
608 "eastoutside", "westoutside", ... |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
609 "northeastoutside", "southeastoutside", ... |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
610 "northwestoutside", "southwestoutside"}; |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
611 addproperty ("location", hlegend, "radio", strjoin (locations, "|")); |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
612 addproperty ("orientation", hlegend, "radio", |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
613 "{vertical}|horizontal"); |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
614 addproperty ("string", hlegend, "any", text_strings); |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
615 addproperty ("textposition", hlegend, "radio", "left|{right}"); |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
616 endif |
17534
ec105d91547e
legend.m: Inherit font properties from current axes. Default interpreter to 'tex'.
Rik <rik@octave.org>
parents:
17533
diff
changeset
|
617 ## Inherit visual properties from legend object |
ec105d91547e
legend.m: Inherit font properties from current axes. Default interpreter to 'tex'.
Rik <rik@octave.org>
parents:
17533
diff
changeset
|
618 fontunits = get (hlegend, "fontunits"); |
ec105d91547e
legend.m: Inherit font properties from current axes. Default interpreter to 'tex'.
Rik <rik@octave.org>
parents:
17533
diff
changeset
|
619 fontangle = get (hlegend, "fontangle"); |
ec105d91547e
legend.m: Inherit font properties from current axes. Default interpreter to 'tex'.
Rik <rik@octave.org>
parents:
17533
diff
changeset
|
620 fontname = get (hlegend, "fontname"); |
16728
5cf7369a74cb
Update legend box when the fontsize changes.
Ben Abbott <bpabbott@mac.com>
parents:
16094
diff
changeset
|
621 fontsize = get (hlegend, "fontsize"); |
17534
ec105d91547e
legend.m: Inherit font properties from current axes. Default interpreter to 'tex'.
Rik <rik@octave.org>
parents:
17533
diff
changeset
|
622 fontweight = get (hlegend, "fontweight"); |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
623 interpreter = get (hlegend, "interpreter"); |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
624 textcolor = get (hlegend, "textcolor"); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
625 ## Add text label to the axis first, checking their extents |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
626 nentries = numel (hplots); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
627 texthandle = []; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
628 maxwidth = 0; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
629 maxheight = 0; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
630 for k = 1 : nentries |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
631 halign = ifelse (strcmp (textpos, "right"), "left", "right"); |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
632 texthandle(end+1) = text (0, 0, text_strings{k}, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
633 "color", textcolor, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
634 "horizontalalignment", halign, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
635 "interpreter", interpreter, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
636 "fontunits", fontunits, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
637 "fontangle", fontangle, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
638 "fontname", fontname, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
639 "fontsize", fontsize, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
640 "fontweight", fontweight, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
641 "userdata", hplots(k)); |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
642 units = get (texthandle(end), "units"); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
643 unwind_protect |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
644 set (texthandle(end), "units", "points"); |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
645 extents = get (texthandle(end), "extent"); |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
646 maxwidth = max (maxwidth, extents(3)); |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
647 maxheight = max (maxheight, extents(4)); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
648 unwind_protect_cleanup |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
649 set (texthandle(end), "units", units); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
650 end_unwind_protect |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
651 endfor |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
652 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
653 num1 = nentries; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
654 if (strcmp (orientation, "vertical")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
655 height = nentries * (ypad + maxheight); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
656 if (outside) |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
657 if (height > ca_pos(4)) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
658 ## Avoid shrinking the height of the axis to zero if outside |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
659 num1 = ca_pos(4) / (maxheight + ypad) / 2; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
660 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
661 else |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
662 if (height > 0.9 * ca_pos(4)) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
663 num1 = 0.9 * ca_pos(4) / (maxheight + ypad); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
664 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
665 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
666 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
667 width = nentries * (ypad + maxwidth); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
668 if (outside) |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
669 if (width > ca_pos(3)) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
670 ## Avoid shrinking the width of the axis to zero if outside |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
671 num1 = ca_pos(3) / (maxwidth + ypad) / 2; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
672 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
673 else |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
674 if (width > 0.9 * ca_pos(3)) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
675 num1 = 0.9 * ca_pos(3) / (maxwidth + ypad); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
676 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
677 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
678 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
679 num2 = ceil (nentries / num1); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
680 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
681 xstep = 3 * xpad + (maxwidth + linelength); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
682 if (strcmp (textpos, "right")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
683 xoffset = xpad; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
684 txoffset = 2 * xpad + linelength; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
685 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
686 xoffset = 2 * xpad + maxwidth; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
687 txoffset = xpad + maxwidth; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
688 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
689 ystep = (ypad + maxheight); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
690 yoffset = ystep / 2; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
691 |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
692 ## Place the legend in the desired location |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
693 if (strcmp (orientation, "vertical")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
694 lpos = [0, 0, num2 * xstep, num1 * ystep]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
695 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
696 lpos = [0, 0, num1 * xstep, num2 * ystep]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
697 endif |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
698 |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
699 gnuplot = strcmp (get (fig, "__graphics_toolkit__"), "gnuplot"); |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
700 if (gnuplot) |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
701 ## Gnuplot places the key (legend) at edge of the figure window. |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
702 ## OpenGL places the legend box at edge of the unmodified axes |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
703 ## position. |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
704 if (isempty (strfind (location, "east"))) |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
705 gnuplot_offset = unmodified_axes_outerposition(1) ... |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
706 + unmodified_axes_outerposition(3) ... |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
707 - unmodified_axes_position(1) ... |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
708 - unmodified_axes_position(3); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
709 else |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
710 gnuplot_offset = unmodified_axes_position(1) ... |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
711 - unmodified_axes_outerposition(1); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
712 endif |
17179
828e8852efa9
legend.m: Add %!demo block showing bug #39697.
Rik <rik@octave.org>
parents:
17174
diff
changeset
|
713 ## FIXME: The "fontsize" is added to match the behavior of OpenGL. |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
714 ## This implies that a change in fontsize should trigger a listener |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
715 ## to update the legend. The "2" was determined using a long legend |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
716 ## key in the absence of any subplots. |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
717 gnuplot_offset = gnuplot_offset - 2 * fontsize; |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
718 else |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
719 gnuplot_offset = 0; |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
720 endif |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
721 |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
722 ## For legend's outside the associated axes postion, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
723 ## align their edge to the unmodified_axes_outerpostion, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
724 ## and adjust the axes postion accordingly. |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
725 switch (location) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
726 case "north" |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
727 if (outside) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
728 lpos = [ca_pos(1) + (ca_pos(3) - lpos(3)) / 2, ... |
12396
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
729 ca_outpos(2) + ca_outpos(4) - lpos(4) - ypad, lpos(3), ... |
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
730 lpos(4)]; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
731 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
732 new_pos = [ca_pos(1), ca_pos(2), ca_pos(3), ca_pos(4) - lpos(4)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
733 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
734 lpos = [ca_pos(1) + (ca_pos(3) - lpos(3)) / 2, ... |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
735 ca_pos(2) + ca_pos(4) - lpos(4) - ypad, lpos(3), lpos(4)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
736 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
737 case "south" |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
738 if (outside) |
12396
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
739 lpos = [ca_pos(1) + (ca_pos(3) - lpos(3)) / 2, ... |
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
740 ca_outpos(2) + ypad, lpos(3), lpos(4)]; |
16910
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
741 new_pos = [ca_pos(1), lpos(2) + lpos(4) + 2 * ypad ... |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
742 + tightinset(2), ca_pos(3), ... |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
743 ca_pos(4) - lpos(4)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
744 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
745 lpos = [ca_pos(1) + (ca_pos(3) - lpos(3)) / 2, ... |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
746 ca_pos(2) + ypad, lpos(3), lpos(4)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
747 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
748 case "east" |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
749 if (outside) |
12396
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
750 lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3) - ypad, ... |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
751 ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, lpos(3), lpos(4)]; |
16910
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
752 new_pos = [ca_pos(1), ca_pos(2), ... |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
753 lpos(1) - 2 * xpad - ca_pos(1) - tightinset(3), ... |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
754 ca_pos(4)]; |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
755 new_pos(3) = new_pos(3) + gnuplot_offset; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
756 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
757 lpos = [ca_pos(1) + ca_pos(3) - lpos(3) - ypad, ... |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
758 ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, lpos(3), lpos(4)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
759 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
760 case "west" |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
761 if (outside) |
12396
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
762 lpos = [ca_outpos(1) + ypad, ... |
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
763 ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, ... |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
764 lpos(3), lpos(4)]; |
16910
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
765 new_pos = [lpos(1) + lpos(3) + 2 * xpad + tightinset(1), ... |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
766 ca_pos(2), ca_pos(3) - lpos(3) - 2 * xpad, ca_pos(4)]; |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
767 new_pos(1) = new_pos(1) - gnuplot_offset; |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
768 new_pos(3) = new_pos(3) + gnuplot_offset; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
769 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
770 lpos = [ca_pos(1) + ypad, ... |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
771 ca_pos(2) + (ca_pos(4) - lpos(4)) / 2, lpos(3), lpos(4)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
772 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
773 case "northeast" |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
774 if (outside) |
12396
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
775 lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3) - ypad, ... |
12395
4d30b4136a3e
legend.m: Align legends to plot box, add demo. Bug 32373.
Ben Abbott <bpabbott@mac.com>
parents:
12394
diff
changeset
|
776 ca_pos(2) + ca_pos(4) - lpos(4), lpos(3), lpos(4)]; |
16910
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
777 new_pos = [ca_pos(1), ca_pos(2), ... |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
778 lpos(1) - 2 * xpad - tightinset(3) - ca_pos(1), ... |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
779 ca_pos(4)]; |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
780 new_pos(3) = new_pos(3) + gnuplot_offset; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
781 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
782 lpos = [ca_pos(1) + ca_pos(3) - lpos(3) - ypad, ... |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
783 ca_pos(2) + ca_pos(4) - lpos(4) - ypad, lpos(3), lpos(4)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
784 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
785 case "northwest" |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
786 if (outside) |
12396
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
787 lpos = [ca_outpos(1) + ypad , ca_pos(2) + ca_pos(4) - lpos(4), ... |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
788 lpos(3), lpos(4)]; |
16910
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
789 new_pos = [lpos(1) + lpos(3) + 2 * xpad + tightinset(1), ... |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
790 ca_pos(2), ca_pos(3) - lpos(3) - 2 * xpad, ca_pos(4)]; |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
791 new_pos(1) = new_pos(1) - gnuplot_offset; |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
792 new_pos(3) = new_pos(3) + gnuplot_offset; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
793 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
794 lpos = [ca_pos(1) + ypad, ... |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
795 ca_pos(2) + ca_pos(4) - lpos(4) - ypad, lpos(3), lpos(4)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
796 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
797 case "southeast" |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
798 if (outside) |
12396
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
799 lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3) - ypad, ... |
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
800 ca_pos(2), lpos(3), lpos(4)]; |
12395
4d30b4136a3e
legend.m: Align legends to plot box, add demo. Bug 32373.
Ben Abbott <bpabbott@mac.com>
parents:
12394
diff
changeset
|
801 new_pos = [ca_pos(1), ca_pos(2), ... |
16910
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
802 lpos(1) - 2 * xpad - ca_pos(1) - tightinset(3), ... |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
803 ca_pos(4)]; |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
804 new_pos(3) = new_pos(3) + gnuplot_offset; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
805 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
806 lpos = [ca_pos(1) + ca_pos(3) - lpos(3) - ypad, ... |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
807 ca_pos(2) + ypad, lpos(3), lpos(4)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
808 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
809 case "southwest" |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
810 if (outside) |
12396
6ba430a75553
Fix for legends with location southeastoutside and soutwestoutside. Pad legend position
David Bateman <dbateman@free.fr>
parents:
12395
diff
changeset
|
811 lpos = [ca_outpos(1) + ypad, ca_pos(2), lpos(3), lpos(4)]; |
16910
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
812 new_pos = [lpos(1) + lpos(3) + 2 * xpad + tightinset(1), ... |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
813 ca_pos(2), ca_pos(3) - lpos(3) - 2 * xpad, ca_pos(4)]; |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
814 new_pos(1) = new_pos(1) - gnuplot_offset; |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
815 new_pos(3) = new_pos(3) + gnuplot_offset; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
816 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
817 lpos = [ca_pos(1) + ypad, ca_pos(2) + ypad, lpos(3), lpos(4)]; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
818 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
819 endswitch |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
820 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
821 units = get (hlegend, "units"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
822 unwind_protect |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
823 set (hlegend, "units", "points"); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12437
diff
changeset
|
824 set (hlegend, "position", lpos); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
825 unwind_protect_cleanup |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
826 set (hlegend, "units", units); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
827 end_unwind_protect |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
828 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
829 ## Now write the line segments and place the text objects correctly |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
830 xk = 0; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
831 yk = 0; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
832 for k = 1 : numel (hplots) |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
833 hobjects(end+1) = texthandle(k); |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11033
diff
changeset
|
834 switch (get (hplots(k), "type")) |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
835 |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
836 case "line" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
837 color = get (hplots(k), "color"); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
838 style = get (hplots(k), "linestyle"); |
18490
be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents:
17885
diff
changeset
|
839 lwidth = min (get (hplots(k), "linewidth"), 5); |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
840 if (! strcmp (style, "none")) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
841 l1 = line ("xdata", ([xoffset, xoffset + linelength] + xk * xstep) / lpos(3), |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
842 "ydata", [1, 1] .* (lpos(4) - yoffset - yk * ystep) / lpos(4), |
18490
be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents:
17885
diff
changeset
|
843 "color", color, "linestyle", style, "linewidth", lwidth, |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
844 "marker", "none", |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
845 "userdata", hplots(k)); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
846 hobjects(end+1) = l1; |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
847 endif |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
848 marker = get (hplots(k), "marker"); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
849 if (! strcmp (marker, "none")) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
850 l1 = line ("xdata", (xoffset + 0.5 * linelength + xk * xstep) / lpos(3), |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
851 "ydata", (lpos(4) - yoffset - yk * ystep) / lpos(4), |
18490
be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents:
17885
diff
changeset
|
852 "color", color, "linestyle", "none", "linewidth", lwidth, |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
853 "marker", marker, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
854 "markeredgecolor",get (hplots(k), "markeredgecolor"), |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
855 "markerfacecolor",get (hplots(k), "markerfacecolor"), |
18491
1597281144e4
legend.m: Restrict maximum marker size to avoid overflowing visual area.
Rik <rik@octave.org>
parents:
18490
diff
changeset
|
856 "markersize", min (get (hplots(k), "markersize"),10), |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
857 "userdata", hplots(k)); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
858 hobjects(end+1) = l1; |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
859 endif |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
860 |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
861 if (addprops) |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
862 addlistener (hplots(k), "color", |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
863 {@updateline, hlegend, linelength, false}); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
864 addlistener (hplots(k), "linestyle", |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
865 {@updateline, hlegend, linelength, false}); |
18490
be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents:
17885
diff
changeset
|
866 addlistener (hplots(k), "linewidth", |
be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents:
17885
diff
changeset
|
867 {@updateline, hlegend, linelength, false}); |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
868 addlistener (hplots(k), "marker", |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
869 {@updateline, hlegend, linelength, false}); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
870 addlistener (hplots(k), "markeredgecolor", |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
871 {@updateline, hlegend, linelength, false}); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
872 addlistener (hplots(k), "markerfacecolor", |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
873 {@updateline, hlegend, linelength, false}); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
874 addlistener (hplots(k), "markersize", |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
875 {@updateline, hlegend, linelength, false}); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
876 addlistener (hplots(k), "displayname", |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
877 {@updateline, hlegend, linelength, true}); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
878 endif |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
879 |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
880 case "patch" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
881 facecolor = get (hplots(k), "facecolor"); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
882 edgecolor = get (hplots(k), "edgecolor"); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
883 cdata = get (hplots(k), "cdata"); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
884 if (! strcmp (facecolor, "none") || ! strcmp (edgecolor, "none")) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
885 p1 = patch ("xdata", ([0, linelength, linelength, 0] + |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
886 xoffset + xk * xstep) / lpos(3), |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
887 "ydata", (lpos(4) - yoffset - |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
888 [yk-0.3, yk-0.3, yk+0.3, yk+0.3] .* ystep) / lpos(4), |
18670
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
889 "facecolor", facecolor, "edgecolor", edgecolor, |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
890 "cdata", cdata, "userdata", hplots(k)); |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
891 else |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
892 ## non-standard patch only making use of marker styles |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
893 ## such as scatter plot. |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
894 p1 = patch ("xdata", (xoffset + 0.5 * linelength + xk * xstep) / lpos(3), |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
895 "ydata", (lpos(4) - yoffset - yk * ystep) / lpos(4), |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
896 "marker", get (hplots(k), "marker"), |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
897 "markeredgecolor",get (hplots(k),"markeredgecolor"), |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
898 "markerfacecolor",get (hplots(k),"markerfacecolor"), |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
899 "markersize", min (get (hplots(k),"markersize"),10), |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
900 "cdata", cdata, "userdata", hplots(k)); |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
901 endif |
18670
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
902 hobjects(end+1) = p1; |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
903 ## Copy clim from axes so that colors work out. |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
904 set (hlegend, "clim", get (ca(1), "clim")); |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
905 |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
906 ## FIXME: Need listeners, as for line objects. |
17730
580990c2ce04
legend.m: Fix legend color for bar graphs (bug #40327)
Rik <rik@octave.org>
parents:
17677
diff
changeset
|
907 ## Changing clim, for example, won't update colors |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
908 |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
909 case "surface" |
17540
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
910 facecolor = get (hplots(k), "facecolor"); |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
911 edgecolor = get (hplots(k), "edgecolor"); |
17560
225ec9a0222a
legend.m: Use axis that legend refers to when calculating color for surface patch label.
Rik <rik@octave.org>
parents:
17540
diff
changeset
|
912 cdata = sum (get (ca(1), "clim")) / 2; |
17540
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
913 if (! strcmp (facecolor, "none") || ! strcmp (edgecolor, "none")) |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
914 p1 = patch ("xdata", ([0, linelength, linelength, 0] + |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
915 xoffset + xk * xstep) / lpos(3), |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
916 "ydata", (lpos(4) - yoffset - |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
917 [yk-0.3, yk-0.3, yk+0.3, yk+0.3] .* ystep) / lpos(4), |
18670
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
918 "facecolor", facecolor, "edgecolor", edgecolor, |
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
919 "cdata", cdata, "userdata", hplots(k)); |
17540
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
920 hobjects(end+1) = p1; |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
921 endif |
18670
3a1a4d587c4e
legend.m: Correctly create legend for scatter plots (bug #33463).
Rik <rik@octave.org>
parents:
18491
diff
changeset
|
922 ## FIXME: Need listeners, as for line objects. |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
923 |
10999
9f45b76c16e3
legend.m: Treat line, patch, and surface objects differetly.
Ben Abbott <bpabbott@mac.com>
parents:
10995
diff
changeset
|
924 endswitch |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
925 |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
926 set (texthandle(k), "position", |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
927 [(txoffset + xk * xstep) / lpos(3), ... |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
928 (lpos(4) - yoffset - yk * ystep) / lpos(4)]); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
929 if (strcmp (orientation, "vertical")) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
930 yk++; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
931 if (yk > num1) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
932 yk = 0; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
933 xk++; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
934 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
935 else |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
936 xk++; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
937 if (xk > num1) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
938 xk = 0; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
939 yk++; |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
940 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
941 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
942 endfor |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
943 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
944 ## Add an invisible text object to original axis |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
945 ## that when it is destroyed will remove the legend |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
946 props = {"parent", ca(1), "tag", "legend", ... |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
947 "handlevisibility", "off", "visible", "off", ... |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
948 "xliminclude", "off", "yliminclude", "off"}; |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
949 t1 = findall (ca(1), "tag", "legend", "type", "text"); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
950 if (isempty (t1)) |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
951 t1 = text (0, 0, "", props{:}); |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
952 set (t1, "deletefcn", {@deletelegend1, hlegend}); |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
953 endif |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
954 if (isprop (hlegend, "unmodified_axes_position")) |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
955 set (hlegend, "unmodified_axes_position", |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
956 unmodified_axes_position, |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
957 "unmodified_axes_outerposition", |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
958 unmodified_axes_outerposition); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
959 else |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
960 addproperty ("unmodified_axes_position", hlegend, |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
961 "data", unmodified_axes_position); |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
962 addproperty ("unmodified_axes_outerposition", hlegend, |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
963 "data", unmodified_axes_outerposition); |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
964 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
965 |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
966 ## Resize the axis that the legend is attached to if the legend is |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
967 ## "outside" the plot and create a listener to resize axis to original |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
968 ## size if the legend is deleted, hidden, or shown. |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
969 if (outside) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
970 for i = 1 : numel (ca) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
971 units = get (ca(i), "units"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
972 unwind_protect |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
973 set (ca(i), "units", "points"); |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
974 if (gnuplot && numel (ca) == 1) |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
975 ## Let Gnuplot handle the positioning of the keybox. |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
976 ## This violates strict Matlab compatibility, but reliably |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
977 ## renders an esthetic result. |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
978 set (ca(i), "position", unmodified_axes_position); |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
979 set (ca(i), "activepositionproperty", "outerposition") |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
980 else |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
981 ## numel (ca) > 1 for axes overlays (like plotyy) |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
982 set (ca(i), "position", new_pos); |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
983 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
984 unwind_protect_cleanup |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
985 set (ca(i), "units", units); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
986 end_unwind_protect |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
987 endfor |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
988 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
989 set (hlegend, "deletefcn", {@deletelegend2, ca, ... |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
990 unmodified_axes_position, ... |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
991 unmodified_axes_outerposition, ... |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
992 t1, hplots}); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
993 addlistener (hlegend, "visible", {@hideshowlegend, ca, ... |
16909
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
994 unmodified_axes_position, ... |
8f9ed9d8a478
Allow gnuplot to handle keybox and axes positioning.
Ben Abbott <bpabbott@mac.com>
parents:
16908
diff
changeset
|
995 new_pos}); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
996 else |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
997 set (hlegend, "deletefcn", {@deletelegend2, ca, [], [], t1, hplots}); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
998 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
999 |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1000 if (! addprops) |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1001 ## Remove listeners on existing legend temporarily to stop recursion. |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1002 dellistener (hlegend, "location"); |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1003 dellistener (hlegend, "orientation"); |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1004 dellistener (hlegend, "string"); |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1005 dellistener (hlegend, "textposition"); |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1006 endif |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1007 |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1008 if (! addprops) |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1009 set (hlegend, "string", text_strings); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1010 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1011 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1012 if (outside) |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1013 set (hlegend, "location", [location "outside"], |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1014 "orientation", orientation, "textposition", textpos); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1015 else |
16796
519343308ab1
Rename "position" variable to "location" in legend.m
Ben Abbott <bpabbott@mac.com>
parents:
16795
diff
changeset
|
1016 set (hlegend, "location", location, "orientation", orientation, |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1017 "textposition", textpos); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1018 endif |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1019 |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1020 if (addprops) |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1021 addlistener (hlegend, "edgecolor", @updatelegendtext); |
17533
bb7756dff055
legend.m: Add listeners for all font properties to update text labels.
Rik <rik@octave.org>
parents:
17532
diff
changeset
|
1022 addlistener (hlegend, "fontangle", @updatelegendtext); |
bb7756dff055
legend.m: Add listeners for all font properties to update text labels.
Rik <rik@octave.org>
parents:
17532
diff
changeset
|
1023 addlistener (hlegend, "fontname", @updatelegendtext); |
bb7756dff055
legend.m: Add listeners for all font properties to update text labels.
Rik <rik@octave.org>
parents:
17532
diff
changeset
|
1024 addlistener (hlegend, "fontweight", @updatelegendtext); |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1025 addlistener (hlegend, "textcolor", @updatelegendtext); |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1026 ## Properties which could change size of box, such as fontsize, |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1027 ## require legend to be redrawn. |
17885
1d109119ac71
legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1028 ## FIXME: fontsize is changed by print.m function during the |
1d109119ac71
legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1029 ## production of a plot for output. This screws things up |
1d109119ac71
legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1030 ## because legend tries to return the axes size to what it |
1d109119ac71
legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1031 ## was when the figure was created, versus what it is now |
1d109119ac71
legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1032 ## when the figure is being printed. Temporary hack is |
1d109119ac71
legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1033 ## good enough for generating the Octave manual which still |
1d109119ac71
legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1034 ## relies on gnuplot for generating images. See bug #40333. |
1d109119ac71
legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1035 if (! gnuplot) |
1d109119ac71
legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1036 addlistener (hlegend, "fontsize", @updatelegend); |
1d109119ac71
legend.m: Don't add listener for 'fontsize' if using gnuplot.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1037 endif |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1038 addlistener (hlegend, "fontunits", @updatelegend); |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1039 addlistener (hlegend, "interpreter", @updatelegend); |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1040 addlistener (hlegend, "location", @updatelegend); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1041 addlistener (hlegend, "orientation", @updatelegend); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1042 addlistener (hlegend, "string", @updatelegend); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1043 addlistener (hlegend, "textposition", @updatelegend); |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1044 ## FIXME: need to add listeners for tightinset and position |
16910
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
1045 ## addlistener (ca, "tightinset", @update????); |
8a4e53cf79c9
Modify the plotbox position relative to the keybox position.
Ben Abbott <bpabbott@mac.com>
parents:
16909
diff
changeset
|
1046 ## addlistener (ca, "position", @update????); |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1047 else |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1048 ## Restore certain listeners |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1049 addlistener (hlegend, "location", @updatelegend); |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1050 addlistener (hlegend, "orientation", @updatelegend); |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1051 addlistener (hlegend, "string", @updatelegend); |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1052 addlistener (hlegend, "textposition", @updatelegend); |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1053 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1054 unwind_protect_cleanup |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1055 set (fig, "currentaxes", curaxes); |
18802
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1056 if (! isempty (oldfig)) |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1057 set (0, "currentfigure", oldfig); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1058 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1059 end_unwind_protect |
6272 | 1060 endif |
6147 | 1061 endif |
1062 | |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1063 if (nargout > 0) |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1064 hleg = hlegend; |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1065 hleg_obj = hobjects; |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1066 hplot = hplots; |
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1067 labels = text_strings; |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1068 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1069 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1070 endfunction |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1071 |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1072 function updatelegend (h, ~) |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1073 persistent recursive = false; |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1074 |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1075 if (! recursive) |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1076 recursive = true; |
12339
eda5eabd5d0b
Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
11587
diff
changeset
|
1077 unwind_protect |
eda5eabd5d0b
Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
11587
diff
changeset
|
1078 hax = getfield (get (h, "userdata"), "handle"); |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1079 [hplots, ~] = __getlegenddata__ (h); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1080 position = get (h, "unmodified_axes_position"); |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1081 outerposition = get (h, "unmodified_axes_outerposition"); |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1082 units = get (hax, "units"); |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1083 set (hax, "units", "points"); |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16921
diff
changeset
|
1084 switch (get (hax, "activepositionproperty")) |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
1085 case "position" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
1086 set (hax, "outerposition", outerposition); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
1087 set (hax, "position", position); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
1088 case "outerposition" |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
1089 set (hax, "position", position); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17125
diff
changeset
|
1090 set (hax, "outerposition", outerposition); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1091 endswitch |
18792
8c0646dd9e5a
legend.m: Fix bug updating plotyy figures (bug #41970).
Rik <rik@octave.org>
parents:
18670
diff
changeset
|
1092 ## Crazy syntax because set() only seems to support row vectors |
8c0646dd9e5a
legend.m: Fix bug updating plotyy figures (bug #41970).
Rik <rik@octave.org>
parents:
18670
diff
changeset
|
1093 set (hax, repmat ({"units"}, [1 numel(hax)]), units(:)'); |
8c0646dd9e5a
legend.m: Fix bug updating plotyy figures (bug #41970).
Rik <rik@octave.org>
parents:
18670
diff
changeset
|
1094 |
8c0646dd9e5a
legend.m: Fix bug updating plotyy figures (bug #41970).
Rik <rik@octave.org>
parents:
18670
diff
changeset
|
1095 h = legend (hax(1), hplots, get (h, "string")); |
12339
eda5eabd5d0b
Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
11587
diff
changeset
|
1096 unwind_protect_cleanup |
eda5eabd5d0b
Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
11587
diff
changeset
|
1097 recursive = false; |
eda5eabd5d0b
Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
11587
diff
changeset
|
1098 end_unwind_protect |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1099 endif |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1100 |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1101 endfunction |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1102 |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1103 function updatelegendtext (h, ~) |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1104 kids = get (h, "children"); |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1105 htext = []; |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1106 for i = 1:numel (kids) |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1107 if (strcmp (get (kids(i), "type"), "text")) |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1108 htext(end+1) = kids(i); |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1109 endif |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1110 endfor |
17533
bb7756dff055
legend.m: Add listeners for all font properties to update text labels.
Rik <rik@octave.org>
parents:
17532
diff
changeset
|
1111 |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1112 tprops = {"fontangle", "fontname", "fontweight", "color"}; |
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1113 lprops = {"fontangle", "fontname", "fontweight", "textcolor"}; |
17533
bb7756dff055
legend.m: Add listeners for all font properties to update text labels.
Rik <rik@octave.org>
parents:
17532
diff
changeset
|
1114 set (htext, tprops, get (h, lprops)); |
17535
5eae41c8c07f
legend.m: Add support for "edgecolor" property.
Rik <rik@octave.org>
parents:
17534
diff
changeset
|
1115 |
5eae41c8c07f
legend.m: Add support for "edgecolor" property.
Rik <rik@octave.org>
parents:
17534
diff
changeset
|
1116 ec = get (h, "edgecolor"); |
5eae41c8c07f
legend.m: Add support for "edgecolor" property.
Rik <rik@octave.org>
parents:
17534
diff
changeset
|
1117 set (h, "xcolor", ec, "ycolor", ec); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1118 endfunction |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1119 |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1120 function hideshowlegend (h, ~, ca, pos1, pos2) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1121 isvisible = strcmp (get (h, "visible"), "off"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1122 if (! isvisible) |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1123 kids = get (h, "children"); |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1124 if (any (! strcmp (get (kids, "visible"), "off"))) |
17533
bb7756dff055
legend.m: Add listeners for all font properties to update text labels.
Rik <rik@octave.org>
parents:
17532
diff
changeset
|
1125 isvisible = true; |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1126 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1127 endif |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1128 |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1129 for i = 1 : numel (ca) |
17125
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
1130 if (isaxes (ca(i)) |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14755
diff
changeset
|
1131 && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"),"off")) |
11149
fe3c3dfc07eb
style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents:
11134
diff
changeset
|
1132 && strcmp (get (ca(i), "beingdeleted"), "off")) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1133 units = get (ca(i), "units"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1134 unwind_protect |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1135 set (ca(i), "units", "points"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1136 if (isvisible) |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12437
diff
changeset
|
1137 set (ca(i), "position", pos2); |
10990
529b36293297
Backed out changeset 6ea65c5de87a
David Bateman <dbateman@free.fr>
parents:
10989
diff
changeset
|
1138 else |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12437
diff
changeset
|
1139 set (ca(i), "position", pos1); |
10990
529b36293297
Backed out changeset 6ea65c5de87a
David Bateman <dbateman@free.fr>
parents:
10989
diff
changeset
|
1140 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1141 unwind_protect_cleanup |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1142 set (ca(i), "units", units); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1143 end_unwind_protect |
10990
529b36293297
Backed out changeset 6ea65c5de87a
David Bateman <dbateman@free.fr>
parents:
10989
diff
changeset
|
1144 endif |
529b36293297
Backed out changeset 6ea65c5de87a
David Bateman <dbateman@free.fr>
parents:
10989
diff
changeset
|
1145 endfor |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1146 endfunction |
10989
6ea65c5de87a
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10949
diff
changeset
|
1147 |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1148 function deletelegend1 (h, ~, ca) |
17125
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
1149 if (isaxes (ca) |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
1150 && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"), "off")) |
11149
fe3c3dfc07eb
style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents:
11134
diff
changeset
|
1151 && strcmp (get (ca, "beingdeleted"), "off")) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1152 delete (ca); |
10989
6ea65c5de87a
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10949
diff
changeset
|
1153 endif |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1154 endfunction |
10989
6ea65c5de87a
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10949
diff
changeset
|
1155 |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1156 function deletelegend2 (h, ~, ca, pos, outpos, t1, hplots) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1157 for i = 1 : numel (ca) |
17125
b5d6314314fc
Change various plot functions to take advantage of new isaxes() function.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
1158 if (isaxes (ca(i)) |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
1159 && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"), "off")) |
11149
fe3c3dfc07eb
style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents:
11134
diff
changeset
|
1160 && strcmp (get (ca(i), "beingdeleted"), "off")) |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1161 if (! isempty (pos) && ! isempty (outpos)) |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1162 units = get (ca(i), "units"); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1163 unwind_protect |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1164 set (ca(i), "units", "points"); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12437
diff
changeset
|
1165 set (ca(i), "position", pos, "deletefcn", ""); |
10995
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1166 unwind_protect_cleanup |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1167 set (ca(i), "units", units); |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1168 end_unwind_protect |
e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
1169 endif |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1170 endif |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1171 endfor |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1172 set (t1, "deletefcn", ""); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1173 delete (t1); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1174 for i = 1 : numel (hplots) |
17536
8a186cd5b9a6
legend.m: Updating of font properties which affect box size, now redraws correctly sized legend.
Rik <rik@octave.org>
parents:
17535
diff
changeset
|
1175 if (ishandle (hplots(i)) && strcmp (get (hplots(i), "type"), "line")) |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
1176 dellistener (hplots(i), "color"); |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
1177 dellistener (hplots(i), "linestyle"); |
18490
be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents:
17885
diff
changeset
|
1178 dellistener (hplots(i), "linewidth"); |
15440
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
1179 dellistener (hplots(i), "marker"); |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
1180 dellistener (hplots(i), "markeredgecolor"); |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
1181 dellistener (hplots(i), "markerfacecolor"); |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
1182 dellistener (hplots(i), "markersize"); |
1db706430c96
Fix legend ('show') to work with DisplayName (bug #33757)
Rik <rik@octave.org>
parents:
15202
diff
changeset
|
1183 dellistener (hplots(i), "displayname"); |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1184 endif |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1185 endfor |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1186 endfunction |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1187 |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1188 function updateline (h, ~, hlegend, linelength, update_name) |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1189 |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1190 if (update_name) |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1191 ## When string changes, have to rebuild legend completely |
12339
eda5eabd5d0b
Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
11587
diff
changeset
|
1192 [hplots, text_strings] = __getlegenddata__ (hlegend); |
18802
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1193 legend (get (hplots(1), "parent"), hplots, text_strings); |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1194 else |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1195 kids = get (hlegend, "children"); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1196 ll = lm = []; |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1197 for i = 1 : numel (kids) |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1198 if (get (kids(i), "userdata") == h |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1199 && strcmp (get (kids(i), "type"), "line")) |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1200 if (strcmp (get (kids(i), "marker"), "none")) |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1201 ll = kids(i); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1202 else |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1203 lm = kids(i); |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1204 endif |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1205 endif |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1206 endfor |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1207 |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1208 [linestyle, marker, displayname] = ... |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1209 get (h, {"linestyle", "marker", "displayname"}){:}; |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1210 |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1211 if (! isempty (ll)) |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1212 [xpos1, ypos1] = get (ll, {"xdata", "ydata"}){:}; |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1213 xpos2 = sum (xpos1) / 2; |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1214 ypos2 = ypos1(1); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1215 delete (ll); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1216 if (! isempty (lm)) |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1217 delete (lm); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1218 endif |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1219 else |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1220 [xpos2, ypos2] = get (lm, {"xdata", "ydata"}){:}; |
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1221 xpos1 = xpos2 + [-0.5, 0.5] * linelength; |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1222 ypos1 = [ypos2, ypos2]; |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1223 delete (lm); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1224 endif |
17537
4f57d4de0383
legend.m: Implement correct listener for DisplayName on line objects.
Rik <rik@octave.org>
parents:
17536
diff
changeset
|
1225 |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1226 if (! strcmp (linestyle, "none")) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
1227 line ("xdata", xpos1, "ydata", ypos1, "color", get (h, "color"), |
18490
be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents:
17885
diff
changeset
|
1228 "linestyle", get (h, "linestyle"), |
be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents:
17885
diff
changeset
|
1229 "linewidth", min (get (h, "linewidth"), 5), |
be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents:
17885
diff
changeset
|
1230 "marker", "none", |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1231 "userdata", h, "parent", hlegend); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1232 endif |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1233 if (! strcmp (marker, "none")) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
1234 line ("xdata", xpos2, "ydata", ypos2, "color", get (h, "color"), |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1235 "marker", marker, "markeredgecolor", get (h, "markeredgecolor"), |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1236 "markerfacecolor", get (h, "markerfacecolor"), |
18491
1597281144e4
legend.m: Restrict maximum marker size to avoid overflowing visual area.
Rik <rik@octave.org>
parents:
18490
diff
changeset
|
1237 "markersize", min (get (h, "markersize"), 10), |
18490
be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents:
17885
diff
changeset
|
1238 "linestyle", "none", |
be3702a2eb8a
legend.m: use linewidth from plot object in drawing legend (bug #41283)
Joachim Wiesemann <gnu@jwiesemann.com>
parents:
17885
diff
changeset
|
1239 "linewidth", min (get (h, "linewidth"), 5), |
11198
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1240 "userdata", h, "parent", hlegend); |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1241 endif |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1242 endif |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1243 endfunction |
9f080d23396f
Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents:
11149
diff
changeset
|
1244 |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1245 |
11418
a140991387fb
legend.m: Add demo to legend for inline key.
Ben Abbott <bpabbott@mac.com>
parents:
11363
diff
changeset
|
1246 %!demo |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1247 %! clf; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1248 %! plot (rand (2)); |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1249 %! title ('legend called with cellstr and string inputs for labels'); |
16728
5cf7369a74cb
Update legend box when the fontsize changes.
Ben Abbott <bpabbott@mac.com>
parents:
16094
diff
changeset
|
1250 %! h = legend ({'foo'}, 'bar'); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1251 %! legend location northeastoutside |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1252 %! set (h, 'fontsize', 20); |
11462
aed2c50c3082
legend.m: legend with more than two inline keys (bug 31991). Add/modifyy demos.
Ben Abbott <bpabbott@mac.com>
parents:
11434
diff
changeset
|
1253 |
aed2c50c3082
legend.m: legend with more than two inline keys (bug 31991). Add/modifyy demos.
Ben Abbott <bpabbott@mac.com>
parents:
11434
diff
changeset
|
1254 %!demo |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1255 %! clf; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1256 %! plot (rand (3)); |
18899
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
1257 %! title ('legend("show") without inputs creates default labels'); |
adb948d7fae4
legend.m: Don't create legend for some inputs for Matlab compatibility (bug #42034)
Rik <rik@octave.org>
parents:
18802
diff
changeset
|
1258 %! h = legend ('show'); |
14236
35903f035390
Escaping strings for legend entries are handled by __go_draw_axes__.
Ben Abbott <bpabbott@mac.com>
parents:
14214
diff
changeset
|
1259 |
35903f035390
Escaping strings for legend entries are handled by __go_draw_axes__.
Ben Abbott <bpabbott@mac.com>
parents:
14214
diff
changeset
|
1260 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1261 %! clf; |
11418
a140991387fb
legend.m: Add demo to legend for inline key.
Ben Abbott <bpabbott@mac.com>
parents:
11363
diff
changeset
|
1262 %! x = 0:1; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1263 %! plot (x,x,';I am Blue;', x,2*x, x,3*x,';I am Red;'); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1264 %! legend location northeastoutside |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1265 %! ## Placing legend inside should return axes to original size |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1266 %! legend location northeast |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1267 %! title ('Blue and Red keys, with Green missing'); |
8343
9f34f7636fe0
legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents:
8291
diff
changeset
|
1268 |
9f34f7636fe0
legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents:
8291
diff
changeset
|
1269 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1270 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1271 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1272 %! title ('incline is blue and decline is green'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1273 %! legend ({'I am blue', 'I am green'}, 'location', 'east'); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1274 %! legend hide |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1275 %! legend show |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
11246
diff
changeset
|
1276 |
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
11246
diff
changeset
|
1277 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1278 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1279 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1280 %! title ('Legend with keys in horizontal orientation'); |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1281 %! legend ({'I am blue', 'I am green'}, ... |
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1282 %! 'location', 'east', 'orientation', 'horizontal'); |
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1283 %! legend boxoff |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1284 %! legend boxon |
11462
aed2c50c3082
legend.m: legend with more than two inline keys (bug 31991). Add/modifyy demos.
Ben Abbott <bpabbott@mac.com>
parents:
11434
diff
changeset
|
1285 |
aed2c50c3082
legend.m: legend with more than two inline keys (bug 31991). Add/modifyy demos.
Ben Abbott <bpabbott@mac.com>
parents:
11434
diff
changeset
|
1286 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1287 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1288 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); |
14529
aabdc8f281f1
legend.m: Change default to boxon for Matlab compatibility (bug #36105).
Rik <octave@nomad.inbox5.com>
parents:
14375
diff
changeset
|
1289 %! title ('Legend with box off'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1290 %! legend ({'I am blue', 'I am green'}, 'location', 'east'); |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1291 %! legend boxoff |
11434
1f54ee6760b5
legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents:
11418
diff
changeset
|
1292 |
1f54ee6760b5
legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents:
11418
diff
changeset
|
1293 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1294 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1295 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); |
17532
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
1296 %! title ('Legend with text to the left of key'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1297 %! legend ({'I am blue', 'I am green'}, 'location', 'east'); |
17532
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
1298 %! legend left |
8343
9f34f7636fe0
legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents:
8291
diff
changeset
|
1299 |
9f34f7636fe0
legend.m: Correct ording of legend labels.
Ben Abbott <bpabbott@mac.com>
parents:
8291
diff
changeset
|
1300 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1301 %! clf; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1302 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); |
17532
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
1303 %! title ({'Use properties to place legend text to the left of key', ... |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1304 %! 'Legend text color is magenta'}); |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1305 %! h = legend ({'I am blue', 'I am green'}, 'location', 'east'); |
17532
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
1306 %! legend ('right'); |
492d609d2d75
legend.m: Default text labels to "right" alignment for Matlab compatibility.
Rik <rik@octave.org>
parents:
17530
diff
changeset
|
1307 %! set (h, 'textposition', 'left'); |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1308 %! set (h, 'textcolor', [1 0 1]); |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1309 |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1310 %!demo |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1311 %! clf; |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1312 %! plot (1:10, 1:10, 1:10, fliplr (1:10)); |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1313 %! title ('Legend is hidden') |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1314 %! legend ({'I am blue', 'I am green'}, 'location', 'east'); |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1315 %! legend hide |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1316 |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1317 %!demo |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1318 %! clf; |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1319 %! x = 0:1; |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1320 %! plot (x,x,';I am Blue;', x,2*x,';I am Green;', x,3*x,';I am Red;'); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1321 %! title ({'Labels are embedded in call to plot', ... |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1322 %! 'Legend is hidden and then shown'}); |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1323 %! legend boxon |
11434
1f54ee6760b5
legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents:
11418
diff
changeset
|
1324 %! legend hide |
1f54ee6760b5
legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents:
11418
diff
changeset
|
1325 %! legend show |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
11246
diff
changeset
|
1326 |
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
11246
diff
changeset
|
1327 %!demo |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1328 %! clf; |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1329 %! x = 0:1; |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1330 %! plot (x, x, ';\alpha;', ... |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1331 %! x, 2*x, ';\beta=2\alpha;', ... |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1332 %! x, 3*x, ';\gamma=3\alpha;'); |
17530 | 1333 %! h = legend (); |
17503
d99785217634
legend.m: Text objects should inherit textcolor, interpreter properties from legend (bug #40064).
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1334 %! set (h, 'interpreter', 'tex'); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1335 %! title ('Labels with interpreted Greek text'); |
11434
1f54ee6760b5
legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents:
11418
diff
changeset
|
1336 |
1f54ee6760b5
legend.m: Only one legend per axes (bug 32022)
Ben Abbott <bpabbott@mac.com>
parents:
11418
diff
changeset
|
1337 %!demo |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1338 %! clf; |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1339 %! plot (rand (2)); |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1340 %! title ('Labels with TeX interpreter turned off'); |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1341 %! h = legend ('Hello_World', 'foo^bar'); |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1342 %! set (h, 'interpreter', 'none'); |
9451 | 1343 |
1344 %!demo | |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1345 %! clf; |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1346 %! plot (1:10, 1:10); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1347 %! title ('a very long label can sometimes cause problems'); |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1348 %! legend ('hello very big world', 'location', 'northeastoutside'); |
9451 | 1349 |
1350 %!demo | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1351 %! clf; |
6146 | 1352 %! labels = {}; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1353 %! colororder = get (gca, 'colororder'); |
6146 | 1354 %! for i = 1:5 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14252
diff
changeset
|
1355 %! h = plot (1:100, i + rand (100,1)); hold on; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1356 %! set (h, 'color', colororder(i,:)); |
14252
4e6436a60b62
Changes to allow plot demos to be run under Matlab.
Ben Abbott <bpabbott@mac.com>
parents:
14245
diff
changeset
|
1357 %! labels = {labels{:}, ['Signal ', num2str(i)]}; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1358 %! end |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
11246
diff
changeset
|
1359 %! hold off; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1360 %! title ({'Signals with random offset and uniform noise'; |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1361 %! 'Legend shown below and outside of plot'}); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1362 %! xlabel ('Sample Nr [k]'); ylabel ('Amplitude [V]'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1363 %! legend (labels, 'location', 'southoutside'); |
9451 | 1364 |
1365 %!demo | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1366 %! clf; |
9451 | 1367 %! x = linspace (0, 10); |
1368 %! plot (x, x); | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1369 %! hold on; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1370 %! stem (x, x.^2, 'g'); |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1371 %! title ('First created object gets first label'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1372 %! legend ('linear'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1373 %! hold off; |
9451 | 1374 |
1375 %!demo | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1376 %! clf; |
9451 | 1377 %! x = linspace (0, 10); |
1378 %! plot (x, x, x, x.^2); | |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1379 %! title ('First created object gets first label'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1380 %! legend ('linear'); |
9451 | 1381 |
1382 %!demo | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1383 %! clf; |
9451 | 1384 %! x = linspace (0, 10); |
1385 %! plot (x, x, x, x.^2); | |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1386 %! title ('Labels are applied in order of object creation'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1387 %! 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
|
1388 |
f9fb8c1a8e45
legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents:
9451
diff
changeset
|
1389 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1390 %! clf; |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
11246
diff
changeset
|
1391 %! rand_2x3_data1 = [0.341447, 0.171220, 0.284370; 0.039773, 0.731725, 0.779382]; |
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
11246
diff
changeset
|
1392 %! bar (rand_2x3_data1); |
13936
bfaacd5e7379
Bug fix (#34901). Allow legend options to be specified. Modify demo.
Ben Abbott <bpabbott@mac.com>
parents:
13279
diff
changeset
|
1393 %! ylim ([0 1.0]); |
17190
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17179
diff
changeset
|
1394 %! title ('legend() works for bar graphs (hggroups)'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1395 %! legend ({'1st Bar', '2nd Bar', '3rd Bar'}); |
9457
f9fb8c1a8e45
legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents:
9451
diff
changeset
|
1396 |
f9fb8c1a8e45
legend.m: Add an hggroup demo using bar(). Include clf() in each demo.
Ben Abbott <bpabbott@mac.com>
parents:
9451
diff
changeset
|
1397 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1398 %! clf; |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
11246
diff
changeset
|
1399 %! rand_2x3_data2 = [0.44804, 0.84368, 0.23012; 0.72311, 0.58335, 0.90531]; |
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
11246
diff
changeset
|
1400 %! bar (rand_2x3_data2); |
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
11246
diff
changeset
|
1401 %! ylim ([0 1.2]); |
17190
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17179
diff
changeset
|
1402 %! title ('legend() works for bar graphs (hggroups)'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1403 %! legend ('1st Bar', '2nd Bar', '3rd Bar'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1404 %! legend right; |
10662
3afcd24ced61
legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
1405 |
3afcd24ced61
legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
1406 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1407 %! clf; |
10662
3afcd24ced61
legend.m: Key labels for specified objects.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
1408 %! x = 0:0.1:7; |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1409 %! h = plot (x,sin(x), x,cos(x), x,sin(x.^2/10), x,cos(x.^2/10)); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1410 %! title ('Only the sin() objects have keylabels'); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14252
diff
changeset
|
1411 %! legend (h([1, 3]), {'sin (x)', 'sin (x^2/10)'}, 'location', 'southwest'); |
11363
a0dfd7e8e3e2
Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents:
11246
diff
changeset
|
1412 |
12340
d63007ac067a
legend.m: Add demo for inline keys created by two plot commands.
Ben Abbott <bpabbott@mac.com>
parents:
12339
diff
changeset
|
1413 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1414 %! clf; |
12340
d63007ac067a
legend.m: Add demo for inline keys created by two plot commands.
Ben Abbott <bpabbott@mac.com>
parents:
12339
diff
changeset
|
1415 %! x = 0:0.1:10; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14252
diff
changeset
|
1416 %! plot (x, sin (x), ';sin (x);'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1417 %! hold all; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14252
diff
changeset
|
1418 %! plot (x, cos (x), ';cos (x);'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1419 %! hold off; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1420 %! title ('legend constructed from multiple plot calls'); |
12340
d63007ac067a
legend.m: Add demo for inline keys created by two plot commands.
Ben Abbott <bpabbott@mac.com>
parents:
12339
diff
changeset
|
1421 |
12387
5fb6ea1bff65
legend.m: Add demo for replacing existing legend.
Ben Abbott <bpabbott@mac.com>
parents:
12340
diff
changeset
|
1422 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1423 %! clf; |
12387
5fb6ea1bff65
legend.m: Add demo for replacing existing legend.
Ben Abbott <bpabbott@mac.com>
parents:
12340
diff
changeset
|
1424 %! x = 0:0.1:10; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14252
diff
changeset
|
1425 %! plot (x, sin (x), ';sin (x);'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1426 %! hold all; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14252
diff
changeset
|
1427 %! plot (x, cos (x), ';cos (x);'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1428 %! hold off; |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1429 %! title ('Specified label text overrides previous labels'); |
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1430 %! legend ({'Sine', 'Cosine'}, 'location', 'northeastoutside'); |
12387
5fb6ea1bff65
legend.m: Add demo for replacing existing legend.
Ben Abbott <bpabbott@mac.com>
parents:
12340
diff
changeset
|
1431 |
12394
c2e1973d870b
legend.m: "legend off" should delete the legend object.
Ben Abbott <bpabbott@mac.com>
parents:
12388
diff
changeset
|
1432 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1433 %! clf; |
12394
c2e1973d870b
legend.m: "legend off" should delete the legend object.
Ben Abbott <bpabbott@mac.com>
parents:
12388
diff
changeset
|
1434 %! x = 0:10; |
c2e1973d870b
legend.m: "legend off" should delete the legend object.
Ben Abbott <bpabbott@mac.com>
parents:
12388
diff
changeset
|
1435 %! plot (x, rand (11)); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1436 %! xlabel ('Indices'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1437 %! ylabel ('Random Values'); |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1438 %! title ('Legend ''off'' deletes the legend'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1439 %! legend (cellstr (num2str ((1:10)')), 'location', 'northeastoutside'); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1440 %! legend off; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1441 %! axis ([0, 10, 0 1]); |
12387
5fb6ea1bff65
legend.m: Add demo for replacing existing legend.
Ben Abbott <bpabbott@mac.com>
parents:
12340
diff
changeset
|
1442 |
12395
4d30b4136a3e
legend.m: Align legends to plot box, add demo. Bug 32373.
Ben Abbott <bpabbott@mac.com>
parents:
12394
diff
changeset
|
1443 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1444 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1445 %! x = (1:5)'; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14252
diff
changeset
|
1446 %! subplot (2,2,1); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1447 %! plot (x, rand (numel (x))); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1448 %! legend (cellstr (num2str (x)), 'location', 'northwestoutside'); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14252
diff
changeset
|
1449 %! subplot (2,2,2); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1450 %! plot (x, rand (numel (x))); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1451 %! legend (cellstr (num2str (x)), 'location', 'northeastoutside'); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14252
diff
changeset
|
1452 %! subplot (2,2,3); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1453 %! plot (x, rand (numel (x))); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1454 %! legend (cellstr (num2str (x)), 'location', 'southwestoutside'); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14252
diff
changeset
|
1455 %! subplot (2,2,4); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1456 %! plot (x, rand (numel (x))); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1457 %! legend (cellstr (num2str (x)), 'location', 'southeastoutside'); |
12387
5fb6ea1bff65
legend.m: Add demo for replacing existing legend.
Ben Abbott <bpabbott@mac.com>
parents:
12340
diff
changeset
|
1458 |
12395
4d30b4136a3e
legend.m: Align legends to plot box, add demo. Bug 32373.
Ben Abbott <bpabbott@mac.com>
parents:
12394
diff
changeset
|
1459 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1460 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14236
diff
changeset
|
1461 %! plot (rand (2)); |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1462 %! title ('legend() will warn if extra labels are specified'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1463 %! legend ('Hello', 'World', 'interpreter', 'foobar'); |
13979
f35b593688a5
Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents:
13937
diff
changeset
|
1464 |
f35b593688a5
Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents:
13937
diff
changeset
|
1465 %!demo |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1466 %! clf; |
14207
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1467 %! x = 0:10; |
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1468 %! y1 = rand (size (x)); |
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1469 %! y2 = rand (size (x)); |
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1470 %! [ax, h1, h2] = plotyy (x, y1, x, y2); |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1471 %! title ('plotyy legend test #1: Blue and Green labels'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1472 %! legend ([h1, h2], {'Blue', 'Green'}, 'location', 'south'); |
12395
4d30b4136a3e
legend.m: Align legends to plot box, add demo. Bug 32373.
Ben Abbott <bpabbott@mac.com>
parents:
12394
diff
changeset
|
1473 |
13979
f35b593688a5
Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents:
13937
diff
changeset
|
1474 %!demo |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1475 %! clf; |
14207
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1476 %! x = 0:10; |
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1477 %! y1 = rand (size (x)); |
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1478 %! y2 = rand (size (x)); |
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1479 %! [ax, h1, h2] = plotyy (x, y1, x, y2); |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1480 %! title ('plotyy legend test #2: Blue and Green labels'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1481 %! legend ({'Blue', 'Green'}, 'location', 'south'); |
13979
f35b593688a5
Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents:
13937
diff
changeset
|
1482 |
f35b593688a5
Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents:
13937
diff
changeset
|
1483 %!demo |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1484 %! clf; |
14207
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1485 %! x = 0:10; |
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1486 %! y1 = rand (size (x)); |
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1487 %! y2 = rand (size (x)); |
57e3490094e1
Fix order of legend entries for plotyy. Bug # 35314.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
1488 %! [ax, h1, h2] = plotyy (x, y1, x, y2); |
15442
015cc3d1f389
legend.m: Overhaul function and add support for automatic data labels.
Rik <rik@octave.org>
parents:
15441
diff
changeset
|
1489 %! title ('plotyy legend test #3: Blue and Green labels'); |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
1490 %! legend ('Blue', 'Green', 'location', 'south'); |
13979
f35b593688a5
Changing the legend's interpreter property should be inherited by the
Ben Abbott <bpabbott@mac.com>
parents:
13937
diff
changeset
|
1491 |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1492 %!demo % bug 36408 |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1493 %! clf; |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1494 %! option = 'right'; |
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1495 %! subplot (3,1,1); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1496 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1497 %! xlabel xlabel; |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1498 %! ylabel ylabel; |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1499 %! title ('Subplots should adjust to the legend placed outside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1500 %! legend ({'1'}, 'location', 'northeastoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1501 %! legend (option); |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1502 %! subplot (3,1,2); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1503 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1504 %! xlabel xlabel; |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1505 %! ylabel ylabel; |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1506 %! legend ({'1234567890'}, 'location', 'eastoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1507 %! legend (option); |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1508 %! subplot (3,1,3); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1509 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1510 %! xlabel xlabel; |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1511 %! ylabel ylabel; |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1512 %! legend ({'12345678901234567890'}, 'location', 'southeastoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1513 %! legend (option); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1514 |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1515 %!demo % bug 36408 |
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1516 %! clf; |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1517 %! option = 'right'; |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1518 %! subplot (3,1,1); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1519 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1520 %! title ('Subplots should adjust to the legend placed outside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1521 %! legend ({'1'}, 'location', 'northwestoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1522 %! legend (option); |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1523 %! subplot (3,1,2); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1524 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1525 %! legend ({'1234567890'}, 'location', 'westoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1526 %! legend (option); |
16805
2281d957cde6
legend.m: Tweak code for Octave coding conventions.
Rik <rik@octave.org>
parents:
16800
diff
changeset
|
1527 %! subplot (3,1,3); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1528 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1529 %! legend ({'12345678901234567890'}, 'location', 'southwestoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1530 %! legend (option); |
16799
286904321282
Use unmodified axes "position" and "outerposition" properties for legend().
Ben Abbott <bpabbott@mac.com>
parents:
16796
diff
changeset
|
1531 |
16908
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1532 %!demo % bug 36408 |
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1533 %! clf; |
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1534 %! option = 'right'; |
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1535 %! subplot (3,1,1); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1536 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1537 %! set (gca (), 'yaxislocation', 'right'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1538 %! xlabel ('xlabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1539 %! ylabel ('ylabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1540 %! title ('Subplots should adjust to the legend placed outside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1541 %! legend ({'1'}, 'location', 'northeastoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1542 %! legend (option); |
16908
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1543 %! subplot (3,1,2); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1544 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1545 %! set (gca (), 'yaxislocation', 'right'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1546 %! xlabel ('xlabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1547 %! ylabel ('ylabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1548 %! legend ({'1234567890'}, 'location', 'eastoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1549 %! legend (option); |
16908
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1550 %! subplot (3,1,3); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1551 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1552 %! set (gca (), 'yaxislocation', 'right'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1553 %! xlabel ('xlabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1554 %! ylabel ('ylabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1555 %! legend ({'12345678901234567890'}, 'location', 'southeastoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1556 %! legend (option); |
16908
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1557 |
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1558 %!demo % bug 36408 |
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1559 %! clf; |
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1560 %! option = 'right'; |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1561 %! subplot (3,1,1); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1562 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1563 %! set (gca (), 'yaxislocation', 'right'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1564 %! xlabel ('xlabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1565 %! ylabel ('ylabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1566 %! title ('Subplots should adjust to the legend placed outside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1567 %! legend ({'1'}, 'location', 'northwestoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1568 %! legend (option); |
16908
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1569 %! subplot (3,1,2); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1570 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1571 %! set (gca (), 'yaxislocation', 'right'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1572 %! xlabel ('xlabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1573 %! ylabel ('ylabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1574 %! legend ({'1234567890'}, 'location', 'westoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1575 %! legend (option); |
16908
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1576 %! subplot (3,1,3); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1577 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1578 %! set (gca (), 'yaxislocation', 'right'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1579 %! xlabel ('xlabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1580 %! ylabel ('ylabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1581 %! legend ({'12345678901234567890'}, 'location', 'southwestoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1582 %! legend (option); |
16908
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1583 |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1584 %!demo % bug 36408; |
16908
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1585 %! clf; |
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1586 %! option = 'right'; |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1587 %! subplot (3,1,1); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1588 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1589 %! set (gca (), 'xaxislocation', 'top'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1590 %! xlabel ('xlabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1591 %! ylabel ('ylabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1592 %! title ('Subplots should adjust to the legend placed outside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1593 %! legend ({'1'}, 'location', 'northwestoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1594 %! legend (option); |
16908
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1595 %! subplot (3,1,2); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1596 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1597 %! set (gca (), 'xaxislocation', 'top'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1598 %! xlabel ('xlabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1599 %! ylabel ('ylabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1600 %! legend ({'1234567890'}, 'location', 'westoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1601 %! legend (option); |
16908
1c4be5dcacd5
Add demos to legend.m using subplots.
Ben Abbott <bpabbott@mac.com>
parents:
16885
diff
changeset
|
1602 %! subplot (3,1,3); |
16921
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1603 %! plot (rand (1,4)); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1604 %! set (gca (), 'xaxislocation', 'top'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1605 %! xlabel ('xlabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1606 %! ylabel ('ylabel'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1607 %! legend ({'12345678901234567890'}, 'location', 'southwestoutside'); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1608 %! legend (option); |
9a316ec12b5f
legend.m: Use Matlab coding conventions in %!demo blocks so comparison script can run.
Rik <rik@octave.org>
parents:
16910
diff
changeset
|
1609 |
17179
828e8852efa9
legend.m: Add %!demo block showing bug #39697.
Rik <rik@octave.org>
parents:
17174
diff
changeset
|
1610 %!demo % bug 39697 |
17190
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17179
diff
changeset
|
1611 %! clf; |
17179
828e8852efa9
legend.m: Add %!demo block showing bug #39697.
Rik <rik@octave.org>
parents:
17174
diff
changeset
|
1612 %! plot (1:10); |
17540
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
1613 %! legend ('Legend Text'); |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
1614 %! title ({'Multi-line', 'titles', 'are a', 'problem'}); |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
1615 |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
1616 %!demo |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
1617 %! clf; |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
1618 %! colormap (cool (64)); |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
1619 %! surf (peaks ()); |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
1620 %! legend ('peaks()') |
b7aa1d726bcc
legend.m: Add support for surface objects.
Rik <rik@octave.org>
parents:
17538
diff
changeset
|
1621 %! title ('legend() works for surface objects too'); |
17179
828e8852efa9
legend.m: Add %!demo block showing bug #39697.
Rik <rik@octave.org>
parents:
17174
diff
changeset
|
1622 |
16973
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1623 %!test |
17107
dbd64c9a16da
Restore graphics toolkit after %!tests that alter it.
Rik <rik@octave.org>
parents:
17065
diff
changeset
|
1624 %! toolkit = graphics_toolkit ("gnuplot"); |
17119
bd50e0660545
test: Add missing semicolons to suppress output in some plot %!tests.
Rik <rik@octave.org>
parents:
17107
diff
changeset
|
1625 %! h = figure ("visible", "off"); |
16973
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1626 %! unwind_protect |
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1627 %! position = get (h, "position"); |
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1628 %! plot (rand (3)); |
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1629 %! legend (); |
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1630 %! filename = sprintf ("%s.eps", tmpnam ()); |
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1631 %! print (filename); |
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1632 %! unlink (filename); |
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1633 %! assert (get (h, "position"), position); |
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1634 %! unwind_protect_cleanup |
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1635 %! close (h); |
17107
dbd64c9a16da
Restore graphics toolkit after %!tests that alter it.
Rik <rik@octave.org>
parents:
17065
diff
changeset
|
1636 %! graphics_toolkit (toolkit); |
16973
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1637 %! end_unwind_protect |
d429a05dc11c
legend.m: Move %!test block below %!demo blocks per standard usage.
Rik <rik@octave.org>
parents:
16933
diff
changeset
|
1638 |
18802
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1639 %!test |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1640 %! ## bug #42035 |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1641 %! h = figure ("visible", "off"); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1642 %! unwind_protect |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1643 %! hax1 = subplot (1,2,1); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1644 %! plot (1:10); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1645 %! hax2 = subplot (1,2,2); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1646 %! plot (1:10); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1647 %! hleg1 = legend (hax1, "foo"); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1648 %! assert (get (hleg1, "userdata").handle, hax1) |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1649 %! assert (gca (), hax2); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1650 %! hleg2 = legend ("bar"); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1651 %! assert (get (hleg2, "userdata").handle, gca ()) |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1652 %! unwind_protect_cleanup |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1653 %! close (h); |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1654 %! end_unwind_protect |
ce36233e4849
legend.m: Correctly handle axis handle as first argument (bug #42035).
Rik <rik@octave.org>
parents:
18792
diff
changeset
|
1655 |