comparison doc/interpreter/plotimages.m @ 20351:d8992a16643c

doc: Clean up m-files which generate images for Manual. * geometryimages.m, interpimages.m, plotimages.m, sparseimages.m, splineimages.m: Use the same style throughout the mi-files. Obey Octave coding conventions.
author Rik <rik@octave.org>
date Thu, 09 Jul 2015 21:38:57 -0700
parents b9d4ccf4291c
children fc3056b9fac0
comparison
equal deleted inserted replaced
20350:b9d4ccf4291c 20351:d8992a16643c
18 18
19 function plotimages (d, nm, typ) 19 function plotimages (d, nm, typ)
20 graphics_toolkit ("qt"); 20 graphics_toolkit ("qt");
21 set_print_size (); 21 set_print_size ();
22 hide_output (); 22 hide_output ();
23 outfile = fullfile (d, strcat (nm, ".", typ)); 23 outfile = fullfile (d, [nm "." typ]);
24 if (strcmp (typ, "png")) 24 if (strcmp (typ, "png"))
25 set (0, "defaulttextfontname", "*"); 25 set (0, "defaulttextfontname", "*");
26 endif 26 endif
27 if (strcmp (typ, "eps")) 27 if (strcmp (typ, "eps"))
28 d_typ = "-depsc2"; 28 d_typ = "-depsc2";
29 else 29 else
30 d_typ = ["-d", typ]; 30 d_typ = ["-d", typ];
31 endif 31 endif
32 32
33 if (strcmp(typ , "txt")) 33 if (strcmp (typ , "txt"))
34 image_as_txt (d, nm); 34 image_as_txt (d, nm);
35 elseif (strcmp (nm, "plot")) 35 elseif (strcmp (nm, "plot"))
36 x = -10:0.1:10; 36 x = -10:0.1:10;
37 plot (x, sin (x)); 37 plot (x, sin (x));
38 xlabel ("x"); 38 xlabel ("x");
76 print (outfile, d_typ); 76 print (outfile, d_typ);
77 elseif (strcmp (nm, "plot3")) 77 elseif (strcmp (nm, "plot3"))
78 t = 0:0.1:10*pi; 78 t = 0:0.1:10*pi;
79 r = linspace (0, 1, numel (t)); 79 r = linspace (0, 1, numel (t));
80 z = linspace (0, 1, numel (t)); 80 z = linspace (0, 1, numel (t));
81 plot3 (r.*sin(t), r.*cos(t), z); 81 plot3 (r.*sin (t), r.*cos (t), z);
82 xlabel ("r.*sin (t)"); 82 xlabel ("r.*sin (t)");
83 ylabel ("r.*cos (t)"); 83 ylabel ("r.*cos (t)");
84 zlabel ("z"); 84 zlabel ("z");
85 title ("plot3 display of 3-D helix"); 85 title ("plot3 display of 3-D helix");
86 print (outfile, d_typ); 86 print (outfile, d_typ);
124 124
125 ## Use this function before plotting commands and after every call to 125 ## Use this function before plotting commands and after every call to
126 ## print since print() resets output to stdout (unfortunately, gnuplot 126 ## print since print() resets output to stdout (unfortunately, gnuplot
127 ## can't pop output as it can the terminal type). 127 ## can't pop output as it can the terminal type).
128 function hide_output () 128 function hide_output ()
129 f = figure (1); 129 hf = figure (1);
130 set (f, "visible", "off"); 130 set (hf, "visible", "off");
131 endfunction 131 endfunction
132 132
133 ## generate something for the texinfo @image command to process 133 ## generate something for the texinfo @image command to process
134 function image_as_txt (d, nm) 134 function image_as_txt (d, nm)
135 fid = fopen (fullfile (d, strcat (nm, ".txt")), "wt"); 135 fid = fopen (fullfile (d, [nm ".txt"]), "wt");
136 fputs (fid, "\n"); 136 fputs (fid, "\n");
137 fputs (fid, "+---------------------------------+\n"); 137 fputs (fid, "+---------------------------------+\n");
138 fputs (fid, "| Image unavailable in text mode. |\n"); 138 fputs (fid, "| Image unavailable in text mode. |\n");
139 fputs (fid, "+---------------------------------+\n"); 139 fputs (fid, "+---------------------------------+\n");
140 fclose (fid); 140 fclose (fid);
141 endfunction 141 endfunction
142