Mercurial > hg > octave-nkf
annotate doc/interpreter/plotimages.m @ 7905:bcacdcc726f7
Allow octave compilation without FLTK/OpenGL
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 09 Jul 2008 11:00:21 -0400 |
parents | 3422f39573b1 |
children | eb63fbe60fab |
rev | line source |
---|---|
7018 | 1 ## Copyright (C) 2007 John W. Eaton and David Bateman |
2 ## | |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
6888 | 19 function plotimages (nm, typ) |
20 bury_output (); | |
7257 | 21 if (strcmp (typ, "png")) |
22 set (0, "defaulttextfontname", "*"); | |
23 endif | |
7256 | 24 if (strcmp(typ , "txt")) |
25 image_as_txt(nm); | |
26 elseif (strcmp (nm, "plot")) | |
6888 | 27 x = -10:0.1:10; |
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 | 30 elseif (strcmp (nm, "hist")) |
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 | 33 elseif (strcmp (nm, "errorbar")) |
34 x = 0:0.1:10; | |
35 y = sin (x); | |
36 yp = 0.1 .* randn (size (x)); | |
37 ym = -0.1 .* randn (size (x)); | |
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 | 40 elseif (strcmp (nm, "polar")) |
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 | 43 elseif (strcmp (nm, "mesh")) |
44 tx = ty = linspace (-8, 8, 41)'; | |
45 [xx, yy] = meshgrid (tx, ty); | |
46 r = sqrt (xx .^ 2 + yy .^ 2) + eps; | |
47 tz = sin (r) ./ r; | |
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 | 50 elseif (strcmp (nm, "plot3")) |
51 t = 0:0.1:10*pi; | |
52 r = linspace (0, 1, numel (t)); | |
53 z = linspace (0, 1, numel (t)); | |
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 | 56 elseif (strcmp (nm, "extended")) |
57 x = 0:0.01:3; | |
58 plot(x,erf(x)); | |
59 hold on; | |
60 plot(x,x,"r"); | |
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 | 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 | 65 else |
66 error ("unrecognized plot requested"); | |
67 endif | |
68 bury_output (); | |
69 endfunction | |
70 | |
71 function bury_output () | |
72 f = figure (1); | |
73 set (f, "visible", "off"); | |
74 endfunction | |
7256 | 75 |
76 ## generate something for the texinfo @image command to process | |
77 function image_as_txt(nm) | |
78 fid = fopen (sprintf ("%s.txt", nm), "wt"); | |
79 fputs (fid, "\n"); | |
80 fputs (fid, "+---------------------------------+\n"); | |
81 fputs (fid, "| Image unavailable in text mode. |\n"); | |
82 fputs (fid, "+---------------------------------+\n"); | |
83 fclose (fid); | |
84 endfunction |