Mercurial > hg > octave-lyh
annotate scripts/plot/private/__errplot__.m @ 10549:95c3e38098bf
Untabify .m scripts
author | Rik <code@nomad.inbox5.com> |
---|---|
date | Fri, 23 Apr 2010 11:28:50 -0700 |
parents | 1aeb39118764 |
children | d8894a2d0a03 |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
7017 | 2 ## Teemu Ikonen |
3718 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
3718 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
3718 | 19 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8506
diff
changeset
|
20 ## -*- texinfo -*- |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8506
diff
changeset
|
21 ## @deftypefn {Function File} {@var{h} =} __errplot__ (@var{fstr}, @var{p}, @dots{}) |
6895 | 22 ## Undocumented internal function. |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8506
diff
changeset
|
23 ## @end deftypefn |
5720 | 24 |
3718 | 25 ## Created: 18.7.2000 |
26 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi> | |
27 ## Keywords: errorbar, plotting | |
28 | |
6405 | 29 function h = __errplot__ (fstr, p, a1, a2, a3, a4, a5, a6) |
5406 | 30 |
6257 | 31 if (nargin < 4 || nargin > 8) # at least two data arguments needed |
6046 | 32 print_usage (); |
4897 | 33 endif |
4007 | 34 |
8259
dad9a322c639
Remove debugging from previous patch
David Bateman <dbateman@free.fr>
parents:
8258
diff
changeset
|
35 [fmt, key] = __pltopt__ ("__errplot__", fstr); |
6146 | 36 |
6172 | 37 [len, nplots] = size (a1); |
8258 | 38 h = []; |
4007 | 39 |
4897 | 40 for i = 1:nplots |
6736 | 41 ## Set the plot type based on linestyle. |
8258 | 42 |
43 if (strcmp (fmt.linestyle, "~")) | |
6736 | 44 ifmt = "yerr"; |
8258 | 45 elseif (strcmp (fmt.linestyle, ">")) |
6736 | 46 ifmt = "xerr"; |
8258 | 47 elseif (strcmp (fmt.linestyle, "~>")) |
6736 | 48 ifmt = "xyerr"; |
8258 | 49 elseif (strcmp (fmt.linestyle, "#")) |
6736 | 50 ifmt = "box"; |
8258 | 51 elseif (strcmp (fmt.linestyle, "#~")) |
6736 | 52 ifmt = "boxy"; |
8258 | 53 elseif (strcmp (fmt.linestyle, "#~>")) |
6736 | 54 ifmt = "boxxy"; |
55 else | |
56 print_usage (); | |
57 endif | |
58 | |
8258 | 59 hg = hggroup ("parent", p); |
60 h = [h; hg]; | |
61 args = __add_datasource__ ("__errplot__", hg, | |
10549 | 62 {"x", "y", "l", "u", "xl", "xu"}); |
8258 | 63 |
64 if (isempty (fmt.color)) | |
65 hl = __line__ (hg, "color", __next_line_color__ ()); | |
66 else | |
67 hl = __line__ (hg, "color", fmt.color); | |
68 endif | |
69 | |
8506 | 70 ## FIXME -- note the code below adds the errorbar data directly as |
71 ## ldata, etc properties of the line objects, as gnuplot can handle | |
72 ## this. Matlab has the errorbar part of the plot as a special line | |
73 ## object with embedded NaNs that draws the three segments of the | |
74 ## bar separately. Should we duplicate Matlab's behavior and stop | |
75 ## using the ldata, etc. properties of the line objects that are | |
76 ## Octace specific? | |
6736 | 77 |
6257 | 78 switch (nargin - 2) |
8258 | 79 case 1 |
10549 | 80 error ("error plot requires 2, 3, 4 or 6 columns"); |
4897 | 81 case 2 |
10549 | 82 set (hl, "xdata", (1:len)'); |
83 set (hl, "ydata", a1(:,i)); | |
84 set (hl, "ldata", a2(:,i)); | |
85 set (hl, "udata", a2(:,i)); | |
4897 | 86 case 3 |
10549 | 87 set (hl, "xdata", a1(:,i)); |
88 set (hl, "ydata", a2(:,i)); | |
89 set (hl, "ldata", a3(:,i)); | |
90 set (hl, "udata", a3(:,i)); | |
4897 | 91 case 4 |
10549 | 92 set (hl, "xdata", a1(:,i)); |
93 set (hl, "ydata", a2(:,i)); | |
6257 | 94 |
10549 | 95 if (index (ifmt, "boxxy") || index (ifmt, "xyerr")) |
96 set (hl, "xldata", a3(:,i)); | |
97 set (hl, "xudata", a3(:,i)); | |
98 set (hl, "ldata", a4(:,i)); | |
99 set (hl, "udata", a4(:,i)); | |
100 elseif (index (ifmt, "xerr")) | |
101 set (hl, "xldata", a3(:,i)); | |
102 set (hl, "xudata", a4(:,i)); | |
103 else | |
104 set (hl, "ldata", a3(:,i)); | |
105 set (hl, "udata", a4(:,i)); | |
106 endif | |
4897 | 107 case 5 |
10549 | 108 error ("error plot requires 2, 3, 4 or 6 columns"); |
4897 | 109 case 6 |
10549 | 110 set (hl, "xdata", a1(:,i)); |
111 set (hl, "ydata", a2(:,i)); | |
112 set (hl, "xldata", a3(:,i)); | |
113 set (hl, "xudata", a4(:,i)); | |
114 set (hl, "ldata", a5(:,i)); | |
115 set (hl, "udata", a6(:,i)); | |
4897 | 116 endswitch |
8258 | 117 |
118 addproperty ("color", hg, "linecolor", get (hl, "color")); | |
119 addproperty ("linewidth", hg, "linelinewidth", get (hl, "linewidth")); | |
120 addproperty ("linestyle", hg, "linelinestyle", get (hl, "linestyle")); | |
121 addproperty ("marker", hg, "linemarker", get (hl, "marker")); | |
122 addproperty ("markerfacecolor", hg, "linemarkerfacecolor", | |
10549 | 123 get (hl, "markerfacecolor")); |
8258 | 124 addproperty ("markeredgecolor", hg, "linemarkerfacecolor", |
10549 | 125 get (hl, "markeredgecolor")); |
8258 | 126 addproperty ("markersize", hg, "linemarkersize", |
10549 | 127 get (hl, "markersize")); |
8258 | 128 |
129 addlistener (hg, "color", @update_props); | |
130 addlistener (hg, "linewidth", @update_props); | |
131 addlistener (hg, "linestyle", @update_props); | |
132 addlistener (hg, "marker", @update_props); | |
133 addlistener (hg, "markerfacecolor", @update_props); | |
134 addlistener (hg, "markersize", @update_props); | |
135 | |
136 addproperty ("xdata", hg, "data", get (hl, "xdata")); | |
137 addproperty ("ydata", hg, "data", get (hl, "ydata")); | |
138 addproperty ("ldata", hg, "data", get (hl, "ldata")); | |
139 addproperty ("udata", hg, "data", get (hl, "udata")); | |
140 addproperty ("xldata", hg, "data", get (hl, "xldata")); | |
141 addproperty ("xudata", hg, "data", get (hl, "xudata")); | |
142 | |
143 addlistener (hg, "xdata", @update_data); | |
144 addlistener (hg, "ydata", @update_data); | |
145 addlistener (hg, "ldata", @update_data); | |
146 addlistener (hg, "udata", @update_data); | |
147 addlistener (hg, "xldata", @update_data); | |
148 addlistener (hg, "xudata", @update_data); | |
149 | |
150 __line__ (hg, "xdata", get (hl, "xdata"), | |
10549 | 151 "ydata", get (hl, "ydata"), |
152 "color", get (hl, "color"), | |
153 "linewidth", get (hl, "linewidth"), | |
154 "linestyle", get (hl, "linestyle"), | |
155 "marker", "none", "parent", hg); | |
5406 | 156 endfor |
157 | |
4007 | 158 endfunction |
8258 | 159 |
160 function update_props (h, d) | |
161 set (get (h, "children"), "color", get (h, "color"), | |
162 "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle"), | |
163 "marker", get (h, "marker"), "markersize", get (h, "markersize"), | |
164 "markerfacecolor", get (h, "markerfacecolor"), | |
165 "markeredgecolor", get (h, "markeredgecolor")); | |
166 endfunction | |
167 | |
168 function update_data (h, d) | |
169 x = get (h, "xdata"); | |
170 y = get (h, "ydata"); | |
171 l = get (h, "ldata"); | |
172 u = get (h, "udata"); | |
173 xl = get (h, "xldata"); | |
174 xu = get (h, "xudata"); | |
175 | |
176 kids = get (h, "children"); | |
177 set (kids(1), "xdata", x, "ydata", y); | |
178 set (kids(2), "xdata", x, "ydata", y, "ldata", l, "udata", u, | |
179 "xldata", xl, "xudata", xu); | |
180 endfunction |