Mercurial > hg > octave-nkf
comparison scripts/plot/plot.m @ 17388:e04847bbcfdf
Squeeze Nd > 2 plot vectors.
* scripts/plot/__plt__.m: Squeeze input plot vectors when ndims>2.
Throw error if there are more than 2 non-singleton dimensions.
* scripts/plot/plot.m: Modify doc-string. Add demos.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sat, 07 Sep 2013 12:21:38 -0400 |
parents | 68bcac3c043a |
children | 0f45d9dd8107 |
comparison
equal
deleted
inserted
replaced
17387:2b4ed68be0d5 | 17388:e04847bbcfdf |
---|---|
67 ## coordinates and the @var{x} coordinates are taken to be the indices of | 67 ## coordinates and the @var{x} coordinates are taken to be the indices of |
68 ## the elements, starting with 1. | 68 ## the elements, starting with 1. |
69 ## | 69 ## |
70 ## @item | 70 ## @item |
71 ## If @var{x} and @var{y} are scalars, a single point is plotted. | 71 ## If @var{x} and @var{y} are scalars, a single point is plotted. |
72 ## | |
73 ## @item | |
74 ## @code{squeeze()} is applied to arguments with more than two dimensions, | |
75 ## but no more than two singleton dimensions. | |
72 ## | 76 ## |
73 ## @item | 77 ## @item |
74 ## If both arguments are vectors, the elements of @var{y} are plotted versus | 78 ## If both arguments are vectors, the elements of @var{y} are plotted versus |
75 ## the elements of @var{x}. | 79 ## the elements of @var{x}. |
76 ## | 80 ## |
243 %! plot (x1,y1,'bo-', x2,y2,'rs-'); | 247 %! plot (x1,y1,'bo-', x2,y2,'rs-'); |
244 %! axis ('tight'); | 248 %! axis ('tight'); |
245 %! title ({'plot() of blue circles ascending and red squares descending'; | 249 %! title ({'plot() of blue circles ascending and red squares descending'; |
246 %! 'connecting lines drawn'}); | 250 %! 'connecting lines drawn'}); |
247 | 251 |
252 %!demo | |
253 %! x = 0:10; | |
254 %! plot (x, rand (numel (x), 3)) | |
255 %! axis ([0 10 0 1]) | |
256 %! title ({'Three random variables', 'x[1x11], y[11x3]'}) | |
257 | |
258 %!demo | |
259 %! x = 0:10; | |
260 %! plot (x, rand (3, numel (x))) | |
261 %! axis ([0 10 0 1]) | |
262 %! title ({'Three random variables', 'x[1x11], y[3x11]'}) | |
263 | |
264 %!demo | |
265 %! x = 0:10; | |
266 %! plot (repmat (x, 2, 1), rand (2, numel (x)), '-s') | |
267 %! axis ([0 10 0 1]) | |
268 %! title ({'Vertical lines with random height and lenths', ... | |
269 %! 'x[2x11], y[2,11]'}) | |
270 | |
271 %!demo | |
272 %! x = 0:10; | |
273 %! plot (repmat (x(:), 1, 2), rand (numel (x), 2)) | |
274 %! axis ([0 10 0 1]) | |
275 %! title ({'Two random variables', 'x[11x2], y[11x2]'}) | |
276 | |
277 %!demo | |
278 %! x = 0:10; | |
279 %! shape = [1, 1, numel(x), 2]; | |
280 %! x = reshape (repmat (x(:), 1, 2), shape); | |
281 %! y = rand (shape); | |
282 %! plot (x, y) | |
283 %! axis ([0 10 0 1]) | |
284 %! title ({'Two random variables', 'squeezed from 4-d arrays'}) | |
285 |