Mercurial > hg > octave-lyh
diff scripts/plot/plot.m @ 17396: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 |
line wrap: on
line diff
--- a/scripts/plot/plot.m +++ b/scripts/plot/plot.m @@ -69,6 +69,10 @@ ## ## @item ## If @var{x} and @var{y} are scalars, a single point is plotted. +## +## @item +## @code{squeeze()} is applied to arguments with more than two dimensions, +## but no more than two singleton dimensions. ## ## @item ## If both arguments are vectors, the elements of @var{y} are plotted versus @@ -245,3 +249,37 @@ %! title ({'plot() of blue circles ascending and red squares descending'; %! 'connecting lines drawn'}); +%!demo +%! x = 0:10; +%! plot (x, rand (numel (x), 3)) +%! axis ([0 10 0 1]) +%! title ({'Three random variables', 'x[1x11], y[11x3]'}) + +%!demo +%! x = 0:10; +%! plot (x, rand (3, numel (x))) +%! axis ([0 10 0 1]) +%! title ({'Three random variables', 'x[1x11], y[3x11]'}) + +%!demo +%! x = 0:10; +%! plot (repmat (x, 2, 1), rand (2, numel (x)), '-s') +%! axis ([0 10 0 1]) +%! title ({'Vertical lines with random height and lenths', ... +%! 'x[2x11], y[2,11]'}) + +%!demo +%! x = 0:10; +%! plot (repmat (x(:), 1, 2), rand (numel (x), 2)) +%! axis ([0 10 0 1]) +%! title ({'Two random variables', 'x[11x2], y[11x2]'}) + +%!demo +%! x = 0:10; +%! shape = [1, 1, numel(x), 2]; +%! x = reshape (repmat (x(:), 1, 2), shape); +%! y = rand (shape); +%! plot (x, y) +%! axis ([0 10 0 1]) +%! title ({'Two random variables', 'squeezed from 4-d arrays'}) +