comparison scripts/plot/stairs.m @ 10549:95c3e38098bf

Untabify .m scripts
author Rik <code@nomad.inbox5.com>
date Fri, 23 Apr 2010 11:28:50 -0700
parents 965487e00282
children 14af8004945d
comparison
equal deleted inserted replaced
10548:479536c5bb10 10549:95c3e38098bf
63 if (nargout > 1) 63 if (nargout > 1)
64 [h, xs, ys] = __stairs__ (false, varargin{:}); 64 [h, xs, ys] = __stairs__ (false, varargin{:});
65 else 65 else
66 oldax = gca (); 66 oldax = gca ();
67 unwind_protect 67 unwind_protect
68 axes (ax); 68 axes (ax);
69 newplot (); 69 newplot ();
70 [h, xxs, yys] = __stairs__ (true, varargin{:}); 70 [h, xxs, yys] = __stairs__ (true, varargin{:});
71 unwind_protect_cleanup 71 unwind_protect_cleanup
72 axes (oldax); 72 axes (oldax);
73 end_unwind_protect 73 end_unwind_protect
74 endif 74 endif
75 if (nargout == 1) 75 if (nargout == 1)
76 xs = h; 76 xs = h;
77 endif 77 endif
83 if (nargin == 2 || ischar (varargin{2})) 83 if (nargin == 2 || ischar (varargin{2}))
84 y = varargin {1}; 84 y = varargin {1};
85 varargin(1) = []; 85 varargin(1) = [];
86 if (ismatrix (y)) 86 if (ismatrix (y))
87 if (isvector (y)) 87 if (isvector (y))
88 y = y(:); 88 y = y(:);
89 endif 89 endif
90 x = 1:rows (y); 90 x = 1:rows (y);
91 endif 91 endif
92 else 92 else
93 x = varargin{1}; 93 x = varargin{1};
114 if (vec_x) 114 if (vec_x)
115 x = repmat (x, [1, nc]); 115 x = repmat (x, [1, nc]);
116 else 116 else
117 [x_nr, x_nc] = size (x); 117 [x_nr, x_nc] = size (x);
118 if (x_nr != nr || x_nc != nc) 118 if (x_nr != nr || x_nc != nc)
119 error ("stairs: argument size mismatch"); 119 error ("stairs: argument size mismatch");
120 endif 120 endif
121 endif 121 endif
122 endif 122 endif
123 123
124 len = 2*nr - 1; 124 len = 2*nr - 1;
141 for i = 1 : length (varargin) 141 for i = 1 : length (varargin)
142 arg = varargin {i}; 142 arg = varargin {i};
143 if ((ischar (arg) || iscell (arg)) && ! have_line_spec) 143 if ((ischar (arg) || iscell (arg)) && ! have_line_spec)
144 [linespec, valid] = __pltopt__ ("stairs", arg, false); 144 [linespec, valid] = __pltopt__ ("stairs", arg, false);
145 if (valid) 145 if (valid)
146 have_line_spec = true; 146 have_line_spec = true;
147 varargin(i) = []; 147 varargin(i) = [];
148 break; 148 break;
149 endif 149 endif
150 endif 150 endif
151 endfor 151 endfor
152 152
153 if (doplot) 153 if (doplot)
154 h = []; 154 h = [];
155 unwind_protect 155 unwind_protect
156 hold_state = get (gca (), "nextplot"); 156 hold_state = get (gca (), "nextplot");
157 for i = 1 : size(y, 2) 157 for i = 1 : size(y, 2)
158 hg = hggroup (); 158 hg = hggroup ();
159 h = [h; hg]; 159 h = [h; hg];
160 args = __add_datasource__ ("stairs", hg, {"x", "y"}, varargin{:}); 160 args = __add_datasource__ ("stairs", hg, {"x", "y"}, varargin{:});
161 161
162 addproperty ("xdata", hg, "data", x(:,i).'); 162 addproperty ("xdata", hg, "data", x(:,i).');
163 addproperty ("ydata", hg, "data", y(:,i).'); 163 addproperty ("ydata", hg, "data", y(:,i).');
164 164
165 addlistener (hg, "xdata", @update_data); 165 addlistener (hg, "xdata", @update_data);
166 addlistener (hg, "ydata", @update_data); 166 addlistener (hg, "ydata", @update_data);
167 167
168 if (have_line_spec) 168 if (have_line_spec)
169 tmp = line (xs(:,i).', ys(:,i).', "color", linespec.color, 169 tmp = line (xs(:,i).', ys(:,i).', "color", linespec.color,
170 "parent", hg); 170 "parent", hg);
171 else 171 else
172 tmp = line (xs(:,i).', ys(:,i).', "color", __next_line_color__ (), 172 tmp = line (xs(:,i).', ys(:,i).', "color", __next_line_color__ (),
173 "parent", hg); 173 "parent", hg);
174 endif 174 endif
175 175
176 addproperty ("color", hg, "linecolor", get (tmp, "color")); 176 addproperty ("color", hg, "linecolor", get (tmp, "color"));
177 addproperty ("linewidth", hg, "linelinewidth", get (tmp, "linewidth")); 177 addproperty ("linewidth", hg, "linelinewidth", get (tmp, "linewidth"));
178 addproperty ("linestyle", hg, "linelinestyle", get (tmp, "linestyle")); 178 addproperty ("linestyle", hg, "linelinestyle", get (tmp, "linestyle"));
179 179
180 addproperty ("marker", hg, "linemarker", get (tmp, "marker")); 180 addproperty ("marker", hg, "linemarker", get (tmp, "marker"));
181 addproperty ("markerfacecolor", hg, "linemarkerfacecolor", 181 addproperty ("markerfacecolor", hg, "linemarkerfacecolor",
182 get (tmp, "markerfacecolor")); 182 get (tmp, "markerfacecolor"));
183 addproperty ("markeredgecolor", hg, "linemarkeredgecolor", 183 addproperty ("markeredgecolor", hg, "linemarkeredgecolor",
184 get (tmp, "markeredgecolor")); 184 get (tmp, "markeredgecolor"));
185 addproperty ("markersize", hg, "linemarkersize", 185 addproperty ("markersize", hg, "linemarkersize",
186 get (tmp, "markersize")); 186 get (tmp, "markersize"));
187 187
188 addlistener (hg, "color", @update_props); 188 addlistener (hg, "color", @update_props);
189 addlistener (hg, "linewidth", @update_props); 189 addlistener (hg, "linewidth", @update_props);
190 addlistener (hg, "linestyle", @update_props); 190 addlistener (hg, "linestyle", @update_props);
191 addlistener (hg, "marker", @update_props); 191 addlistener (hg, "marker", @update_props);
192 addlistener (hg, "markerfacecolor", @update_props); 192 addlistener (hg, "markerfacecolor", @update_props);
193 addlistener (hg, "markeredgecolor", @update_props); 193 addlistener (hg, "markeredgecolor", @update_props);
194 addlistener (hg, "markersize", @update_props); 194 addlistener (hg, "markersize", @update_props);
195 195
196 if (! isempty (args)) 196 if (! isempty (args))
197 set (hg, args{:}); 197 set (hg, args{:});
198 endif 198 endif
199 endfor 199 endfor
200 unwind_protect_cleanup 200 unwind_protect_cleanup
201 set (gca (), "nextplot", hold_state); 201 set (gca (), "nextplot", hold_state);
202 end_unwind_protect 202 end_unwind_protect
203 else 203 else