annotate scripts/plot/__go_draw_figure__.m @ 11198:9f080d23396f

Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
author David Bateman <dbateman@free.fr>
date Sun, 07 Nov 2010 22:35:40 +0100
parents f0e9befd6a1c
children d2f3a904ac6b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8889
diff changeset
1 ## Copyright (C) 2005, 2007, 2008, 2009 John W. Eaton
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
2 ##
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
4 ##
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## your option) any later version.
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
9 ##
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
14 ##
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
18
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
19 ## -*- texinfo -*-
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
20 ## @deftypefn {Function File} {} __go_draw_figure__ (@var{h}, @var{plot_stream}, @var{enhanced}, @var{mono})
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6619
diff changeset
21 ## Undocumented internal function.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
22 ## @end deftypefn
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
23
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
24 ## Author: jwe
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
25
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10725
diff changeset
26 function __go_draw_figure__ (h, plot_stream, enhanced, mono)
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
27
10913
dd6b90f44ae5 Unify gnuplot printing with the fltk backend.
Ben Abbott <bpabbott@mac.com>
parents: 10725
diff changeset
28 if (nargin == 4)
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8224
diff changeset
29 htype = get (h, "type");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8224
diff changeset
30 if (strcmp (htype, "figure"))
9098
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
31 ## Get complete list of children.
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
32 kids = allchild (h);
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
33 nkids = length (kids);
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
34
9098
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
35 if (nkids > 0)
10473
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
36 fputs (plot_stream, "\nreset;\n");
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
37 fputs (plot_stream, "set autoscale keepfix;\n");
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
38 fputs (plot_stream, "set origin 0, 0\n");
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
39 fputs (plot_stream, "set size 1, 1\n");
10119
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
40 bg = get (h, "color");
10136
ee18258bc002 Also treat white figure and axes color properties
David Bateman <dbateman@free.fr>
parents: 10120
diff changeset
41 if (isnumeric (bg))
10119
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
42 fprintf (plot_stream, "set obj 1 rectangle from screen 0,0 to screen 1,1 behind fc rgb \"#%02x%02x%02x\"\n", 255 * bg);
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
43 bg_is_set = true;
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
44 else
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
45 bg_is_set = false;
1e38d9ed1e28 Respect figure and axes color properties for gnuplot backend
David Bateman <dbateman@free.fr>
parents: 9944
diff changeset
46 endif
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
47
10473
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
48 for i = nkids:-1:1
10568
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
49 type = get (kids(i), "type");
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
50 switch (type)
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
51 case "axes"
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10913
diff changeset
52 if (strcmpi (get (kids (i), "tag"), "legend"))
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
53 ## This is so ugly. If there was a way of getting
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
54 ## gnuplot to give us the text extents of strings
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
55 ## then we could get rid of this mess.
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
56 lh = getfield (get (kids(i), "userdata"), "handle");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
57 if (isscalar (lh))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
58 ## We have a legend with a single parent. It'll be handled
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
59 ## below as a gnuplot key to the axis it corresponds to
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
60 continue;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
61 else
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
62 ca = lh(1);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
63 ## Rely upon listener to convert axes position
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
64 ## to "normalized" units.
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
65 legend_axes_units = get (kids(i), "units");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
66 legend_axes_position = get (kids(i), "position");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
67 legend_axes_outerposition = get (kids(i), "outerposition");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
68 legend_axes_box = get (kids(i), "box");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
69 legend_axes_ylim = get (kids(i), "ylim");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
70 orig_axes_units = get (ca, "units");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
71 hlgnd = get (kids(i));
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
72
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
73 unwind_protect
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
74 set (ca, "units", "normalized");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
75 set (kids(i), "units", "normalized", "box", "off",
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
76 "ylim", [-2, -1], "position", get (ca(1), "position"),
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
77 "outerposition", get (ca(1), "outerposition"));
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10913
diff changeset
78
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
79 ## Create a new set of lines with the appropriate
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
80 ## displaynames, etc
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
81 toberm = [];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
82 hobj = get (kids(i), "children");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
83 for j = numel (hobj) : -1 : 1
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
84 if (! strcmp (get (hobj(j), "type"), "text"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
85 continue;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
86 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
87 displayname = get (hobj(j), "string");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
88 ll = [];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
89 lm = [];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
90 for k = numel (hobj) : -1 : 1
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
91 if (! strcmp (get (hobj(k), "type"), "line"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
92 continue;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
93 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
94 if (get (hobj(j), "userdata")
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
95 != get (hobj(k), "userdata"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
96 continue;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
97 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
98 if (! strcmp (get (hobj(k), "linestyle"), "none"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
99 ll = hobj(k);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
100 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
101 if (! strcmp (get (hobj(k), "marker"), "none"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
102 lm = hobj(k);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
103 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
104 endfor
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
105
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
106 if (! isempty (ll))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
107 if (!isempty (lm))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
108 toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(lm,"color"), "linestyle", get(ll,"linestyle"), "marker", get(lm,"marker"), "markeredgecolor", get(lm,"markeredgecolor"), "markerfacecolor", get(lm,"markerfacecolor"), "markersize", get (lm, "markersize"), "displayname", displayname, "parent", kids(i))];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
109 else
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
110 toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(ll,"color"), "linestyle", get(ll,"linestyle"), "marker", "none", "displayname", displayname, "parent", kids(i))];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
111 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
112 elseif (! isempty (lm))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
113 toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(lm,"color"), "linestyle", "none", "marker", get(lm,"marker"), "markeredgecolor", get(lm,"markeredgecolor"), "markerfacecolor", get(lm,"markerfacecolor"), "markersize", get (lm, "markersize"), "displayname", displayname, "parent", kids(i))];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
114 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
115 endfor
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
116 if (bg_is_set)
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
117 fprintf (plot_stream, "set border linecolor rgb \"#%02x%02x%02x\"\n", 255 * (1 - bg));
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
118 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
119 __go_draw_axes__ (kids(i), plot_stream, enhanced, mono,
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
120 bg_is_set, hlgnd);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
121 unwind_protect_cleanup
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
122 ## Return axes "units" and "position" back to
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
123 ## their original values.
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
124 set (ca, "units", orig_axes_units);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
125 set (kids(i), "units", legend_axes_units,
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
126 "box", legend_axes_box,
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
127 "ylim", legend_axes_ylim,
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
128 "position", legend_axes_position,
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
129 "outerposition", legend_axes_outerposition);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
130 delete (toberm);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
131 bg_is_set = false;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
132 end_unwind_protect
10725
3c59ce262c66 Add the whitebg function
David Bateman <dbateman@free.fr>
parents: 10568
diff changeset
133 endif
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
134 else
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
135 ## Rely upon listener to convert axes position
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
136 ## to "normalized" units.
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
137 orig_axes_units = get (kids(i), "units");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
138 orig_axes_position = get (kids(i), "position");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
139 unwind_protect
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
140 set (kids(i), "units", "normalized");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
141 fg = get (kids(i), "color");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
142 if (isnumeric (fg) && strcmp (get (kids(i), "visible"), "on"))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
143 fprintf (plot_stream, "set obj 2 rectangle from graph 0,0 to graph 1,1 behind fc rgb \"#%02x%02x%02x\"\n", 255 * fg);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
144 fg_is_set = true;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
145 else
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
146 fg_is_set = false;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
147 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
148 if (bg_is_set)
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
149 fprintf (plot_stream, "set border linecolor rgb \"#%02x%02x%02x\"\n", 255 * (1 - bg));
10995
e81914f3921f Update legend code to support fltk (fixes #29348 and partially fixes #30461)
David Bateman <dbateman@free.fr>
parents: 10913
diff changeset
150 endif
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
151 ## Find if this axes has an associated legend axes and pass it
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
152 ## to __go_draw_axes__
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
153 hlegend = [];
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
154 fkids = get (h, "children");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
155 for j = 1 : numel(fkids)
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
156 if (ishandle (fkids (j))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
157 && strcmp (get (fkids (j), "type"), "axes")
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
158 && (strcmp (get (fkids (j), "tag"), "legend")))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
159 udata = get (fkids (j), "userdata");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
160 if (isscalar(udata.handle)
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
161 && ! isempty (intersect (udata.handle, kids (i))))
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
162 hlegend = get (fkids (j));
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
163 break;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
164 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
165 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
166 endfor
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
167 __go_draw_axes__ (kids(i), plot_stream, enhanced, mono,
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
168 bg_is_set, hlegend);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
169 unwind_protect_cleanup
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
170 ## Return axes "units" and "position" back to
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
171 ## their original values.
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
172 set (kids(i), "units", orig_axes_units);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
173 set (kids(i), "position", orig_axes_position);
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
174 bg_is_set = false;
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
175 if (fg_is_set)
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
176 fputs (plot_stream, "unset obj 2\n");
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
177 endif
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
178 end_unwind_protect
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11155
diff changeset
179 endif
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 10995
diff changeset
180 case "uimenu"
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 10995
diff changeset
181 ## ignore uimenu objects
10568
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
182 otherwise
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
183 error ("__go_draw_figure__: unknown object class, %s", type);
046b713d21dc __go_draw_figure__.m: Hidden axes may have visible children.
Ben Abbott <bpabbott@mac.com>
parents: 10528
diff changeset
184 endswitch
10473
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
185 endfor
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
186 fputs (plot_stream, "\nunset multiplot;\n");
9098
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
187 else
10473
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
188 fputs (plot_stream, "\nreset; clear;\n");
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
189 fflush (plot_stream);
9098
5ecdb3d3568f Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents: 9062
diff changeset
190 endif
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
191 else
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
192 error ("__go_draw_figure__: expecting figure object, found `%s'",
10473
169be980faf9 __go_draw_figure__.m: Untabify.
Ben Abbott <bpabbott@mac.com>
parents: 10159
diff changeset
193 htype);
6405
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
194 endif
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
195 else
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
196 print_usage ();
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
197 endif
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
198
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
199 endfunction
b298a4c12fc3 [project @ 2007-03-14 16:51:28 by jwe]
jwe
parents:
diff changeset
200