annotate doc/interpreter/plotimages.m @ 8920:eb63fbe60fab

update copyright notices
author John W. Eaton <jwe@octave.org>
date Sat, 07 Mar 2009 10:41:27 -0500
parents 3422f39573b1
children 77e71f3da3d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 7540
diff changeset
1 ## Copyright (C) 2007, 2008 John W. Eaton and David Bateman
7018
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
2 ##
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
3 ## This file is part of Octave.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
4 ##
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
6 ## under the terms of the GNU General Public License as published by
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
8 ## your option) any later version.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
9 ##
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
13 ## General Public License for more details.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
14 ##
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
15 ## You should have received a copy of the GNU General Public License
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
17 ## <http://www.gnu.org/licenses/>.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6888
diff changeset
18
6888
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
19 function plotimages (nm, typ)
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
20 bury_output ();
7257
e8a3e3e33490 [project @ 2007-12-05 01:18:41 by jwe]
jwe
parents: 7256
diff changeset
21 if (strcmp (typ, "png"))
e8a3e3e33490 [project @ 2007-12-05 01:18:41 by jwe]
jwe
parents: 7256
diff changeset
22 set (0, "defaulttextfontname", "*");
e8a3e3e33490 [project @ 2007-12-05 01:18:41 by jwe]
jwe
parents: 7256
diff changeset
23 endif
7256
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
24 if (strcmp(typ , "txt"))
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
25 image_as_txt(nm);
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
26 elseif (strcmp (nm, "plot"))
6888
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
27 x = -10:0.1:10;
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
28 plot (x, sin (x));
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7257
diff changeset
29 print (cstrcat (nm, ".", typ), cstrcat ("-d", typ))
6888
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
30 elseif (strcmp (nm, "hist"))
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
31 hist (randn (10000, 1), 30);
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7257
diff changeset
32 print (cstrcat (nm, ".", typ), cstrcat ("-d", typ))
6888
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
33 elseif (strcmp (nm, "errorbar"))
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
34 x = 0:0.1:10;
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
35 y = sin (x);
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
36 yp = 0.1 .* randn (size (x));
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
37 ym = -0.1 .* randn (size (x));
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
38 errorbar (x, sin (x), ym, yp);
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7257
diff changeset
39 print (cstrcat (nm, ".", typ), cstrcat ("-d", typ))
6888
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
40 elseif (strcmp (nm, "polar"))
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
41 polar (0:0.1:10*pi, 0:0.1:10*pi);
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7257
diff changeset
42 print (cstrcat (nm, ".", typ), cstrcat ("-d", typ))
6888
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
43 elseif (strcmp (nm, "mesh"))
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
44 tx = ty = linspace (-8, 8, 41)';
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
45 [xx, yy] = meshgrid (tx, ty);
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
46 r = sqrt (xx .^ 2 + yy .^ 2) + eps;
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
47 tz = sin (r) ./ r;
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
48 mesh (tx, ty, tz);
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7257
diff changeset
49 print (cstrcat (nm, ".", typ), cstrcat ("-d", typ))
6888
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
50 elseif (strcmp (nm, "plot3"))
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
51 t = 0:0.1:10*pi;
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
52 r = linspace (0, 1, numel (t));
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
53 z = linspace (0, 1, numel (t));
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
54 plot3 (r.*sin(t), r.*cos(t), z);
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7257
diff changeset
55 print (cstrcat (nm, ".", typ), cstrcat ("-d", typ))
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7018
diff changeset
56 elseif (strcmp (nm, "extended"))
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7018
diff changeset
57 x = 0:0.01:3;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7018
diff changeset
58 plot(x,erf(x));
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7018
diff changeset
59 hold on;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7018
diff changeset
60 plot(x,x,"r");
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7018
diff changeset
61 axis([0, 3, 0, 1]);
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7257
diff changeset
62 text(0.65, 0.6175, cstrcat('\leftarrow x = {2/\surd\pi {\fontsize{16}',
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7018
diff changeset
63 '\int_{\fontsize{8}0}^{\fontsize{8}x}} e^{-t^2} dt} = 0.6175'))
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7257
diff changeset
64 print (cstrcat (nm, ".", typ), cstrcat ("-d", typ))
6888
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
65 else
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
66 error ("unrecognized plot requested");
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
67 endif
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
68 bury_output ();
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
69 endfunction
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
70
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
71 function bury_output ()
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
72 f = figure (1);
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
73 set (f, "visible", "off");
b3d286e8a243 [project @ 2007-09-12 06:40:58 by jwe]
jwe
parents:
diff changeset
74 endfunction
7256
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
75
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
76 ## generate something for the texinfo @image command to process
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
77 function image_as_txt(nm)
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
78 fid = fopen (sprintf ("%s.txt", nm), "wt");
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
79 fputs (fid, "\n");
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
80 fputs (fid, "+---------------------------------+\n");
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
81 fputs (fid, "| Image unavailable in text mode. |\n");
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
82 fputs (fid, "+---------------------------------+\n");
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
83 fclose (fid);
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7189
diff changeset
84 endfunction