Mercurial > hg > octave-nkf
annotate scripts/plot/__errplot__.m @ 8653:2479ebf1c33f
doc/interpreter/system.txi: remove reference to 'eomdate'
author | Soren Hauberg <hauberg@gmail.com> |
---|---|
date | Sun, 01 Feb 2009 16:30:29 +0100 |
parents | bc982528de11 |
children | 7d48766c21a5 |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 |
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 |
6895 | 20 ## Undocumented internal function. |
5720 | 21 |
3718 | 22 ## Created: 18.7.2000 |
23 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi> | |
24 ## Keywords: errorbar, plotting | |
25 | |
6405 | 26 function h = __errplot__ (fstr, p, a1, a2, a3, a4, a5, a6) |
5406 | 27 |
6257 | 28 if (nargin < 4 || nargin > 8) # at least two data arguments needed |
6046 | 29 print_usage (); |
4897 | 30 endif |
4007 | 31 |
8259
dad9a322c639
Remove debugging from previous patch
David Bateman <dbateman@free.fr>
parents:
8258
diff
changeset
|
32 [fmt, key] = __pltopt__ ("__errplot__", fstr); |
6146 | 33 |
6172 | 34 [len, nplots] = size (a1); |
8258 | 35 h = []; |
4007 | 36 |
4897 | 37 for i = 1:nplots |
6736 | 38 ## Set the plot type based on linestyle. |
8258 | 39 |
40 if (strcmp (fmt.linestyle, "~")) | |
6736 | 41 ifmt = "yerr"; |
8258 | 42 elseif (strcmp (fmt.linestyle, ">")) |
6736 | 43 ifmt = "xerr"; |
8258 | 44 elseif (strcmp (fmt.linestyle, "~>")) |
6736 | 45 ifmt = "xyerr"; |
8258 | 46 elseif (strcmp (fmt.linestyle, "#")) |
6736 | 47 ifmt = "box"; |
8258 | 48 elseif (strcmp (fmt.linestyle, "#~")) |
6736 | 49 ifmt = "boxy"; |
8258 | 50 elseif (strcmp (fmt.linestyle, "#~>")) |
6736 | 51 ifmt = "boxxy"; |
52 else | |
53 print_usage (); | |
54 endif | |
55 | |
8258 | 56 hg = hggroup ("parent", p); |
57 h = [h; hg]; | |
58 args = __add_datasource__ ("__errplot__", hg, | |
59 {"x", "y", "l", "u", "xl", "xu"}); | |
60 | |
61 if (isempty (fmt.color)) | |
62 hl = __line__ (hg, "color", __next_line_color__ ()); | |
63 else | |
64 hl = __line__ (hg, "color", fmt.color); | |
65 endif | |
66 | |
8506 | 67 ## FIXME -- note the code below adds the errorbar data directly as |
68 ## ldata, etc properties of the line objects, as gnuplot can handle | |
69 ## this. Matlab has the errorbar part of the plot as a special line | |
70 ## object with embedded NaNs that draws the three segments of the | |
71 ## bar separately. Should we duplicate Matlab's behavior and stop | |
72 ## using the ldata, etc. properties of the line objects that are | |
73 ## Octace specific? | |
6736 | 74 |
6257 | 75 switch (nargin - 2) |
8258 | 76 case 1 |
77 error ("error plot requires 2, 3, 4 or 6 columns"); | |
4897 | 78 case 2 |
8258 | 79 set (hl, "xdata", (1:len)'); |
80 set (hl, "ydata", a1(:,i)); | |
81 set (hl, "ldata", a2(:,i)); | |
82 set (hl, "udata", a2(:,i)); | |
4897 | 83 case 3 |
8258 | 84 set (hl, "xdata", a1(:,i)); |
85 set (hl, "ydata", a2(:,i)); | |
86 set (hl, "ldata", a3(:,i)); | |
87 set (hl, "udata", a3(:,i)); | |
4897 | 88 case 4 |
8258 | 89 set (hl, "xdata", a1(:,i)); |
90 set (hl, "ydata", a2(:,i)); | |
6257 | 91 |
6168 | 92 if (index (ifmt, "boxxy") || index (ifmt, "xyerr")) |
8258 | 93 set (hl, "xldata", a3(:,i)); |
94 set (hl, "xudata", a3(:,i)); | |
95 set (hl, "ldata", a4(:,i)); | |
96 set (hl, "udata", a4(:,i)); | |
6168 | 97 elseif (index (ifmt, "xerr")) |
8258 | 98 set (hl, "xldata", a3(:,i)); |
99 set (hl, "xudata", a4(:,i)); | |
4897 | 100 else |
8258 | 101 set (hl, "ldata", a3(:,i)); |
102 set (hl, "udata", a4(:,i)); | |
4897 | 103 endif |
104 case 5 | |
105 error ("error plot requires 2, 3, 4 or 6 columns"); | |
106 case 6 | |
8258 | 107 set (hl, "xdata", a1(:,i)); |
108 set (hl, "ydata", a2(:,i)); | |
109 set (hl, "xldata", a3(:,i)); | |
110 set (hl, "xudata", a4(:,i)); | |
111 set (hl, "ldata", a5(:,i)); | |
112 set (hl, "udata", a6(:,i)); | |
4897 | 113 endswitch |
8258 | 114 |
115 addproperty ("color", hg, "linecolor", get (hl, "color")); | |
116 addproperty ("linewidth", hg, "linelinewidth", get (hl, "linewidth")); | |
117 addproperty ("linestyle", hg, "linelinestyle", get (hl, "linestyle")); | |
118 addproperty ("marker", hg, "linemarker", get (hl, "marker")); | |
119 addproperty ("markerfacecolor", hg, "linemarkerfacecolor", | |
120 get (hl, "markerfacecolor")); | |
121 addproperty ("markeredgecolor", hg, "linemarkerfacecolor", | |
122 get (hl, "markeredgecolor")); | |
123 addproperty ("markersize", hg, "linemarkersize", | |
124 get (hl, "markersize")); | |
125 | |
126 addlistener (hg, "color", @update_props); | |
127 addlistener (hg, "linewidth", @update_props); | |
128 addlistener (hg, "linestyle", @update_props); | |
129 addlistener (hg, "marker", @update_props); | |
130 addlistener (hg, "markerfacecolor", @update_props); | |
131 addlistener (hg, "markersize", @update_props); | |
132 | |
133 addproperty ("xdata", hg, "data", get (hl, "xdata")); | |
134 addproperty ("ydata", hg, "data", get (hl, "ydata")); | |
135 addproperty ("ldata", hg, "data", get (hl, "ldata")); | |
136 addproperty ("udata", hg, "data", get (hl, "udata")); | |
137 addproperty ("xldata", hg, "data", get (hl, "xldata")); | |
138 addproperty ("xudata", hg, "data", get (hl, "xudata")); | |
139 | |
140 addlistener (hg, "xdata", @update_data); | |
141 addlistener (hg, "ydata", @update_data); | |
142 addlistener (hg, "ldata", @update_data); | |
143 addlistener (hg, "udata", @update_data); | |
144 addlistener (hg, "xldata", @update_data); | |
145 addlistener (hg, "xudata", @update_data); | |
146 | |
147 __line__ (hg, "xdata", get (hl, "xdata"), | |
148 "ydata", get (hl, "ydata"), | |
149 "color", get (hl, "color"), | |
150 "linewidth", get (hl, "linewidth"), | |
151 "linestyle", get (hl, "linestyle"), | |
152 "marker", "none", "parent", hg); | |
5406 | 153 endfor |
154 | |
4007 | 155 endfunction |
8258 | 156 |
157 function update_props (h, d) | |
158 set (get (h, "children"), "color", get (h, "color"), | |
159 "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle"), | |
160 "marker", get (h, "marker"), "markersize", get (h, "markersize"), | |
161 "markerfacecolor", get (h, "markerfacecolor"), | |
162 "markeredgecolor", get (h, "markeredgecolor")); | |
163 endfunction | |
164 | |
165 function update_data (h, d) | |
166 x = get (h, "xdata"); | |
167 y = get (h, "ydata"); | |
168 l = get (h, "ldata"); | |
169 u = get (h, "udata"); | |
170 xl = get (h, "xldata"); | |
171 xu = get (h, "xudata"); | |
172 | |
173 kids = get (h, "children"); | |
174 set (kids(1), "xdata", x, "ydata", y); | |
175 set (kids(2), "xdata", x, "ydata", y, "ldata", l, "udata", u, | |
176 "xldata", xl, "xudata", xu); | |
177 endfunction |