Mercurial > octave
annotate doc/interpreter/plotimages.m @ 31247:3dae836c598c
doc: Expand and edit documentation for memoization (bug #60860)
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Fri, 30 Sep 2022 06:38:59 -0400 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29451
diff
changeset
|
3 ## Copyright (C) 2007-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27847
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
7018 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24462
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7018 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24462
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
7018 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
7018 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
21 ## along with Octave; see the file COPYING. If not, see | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24462
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
7018 | 25 |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19791
diff
changeset
|
26 function plotimages (d, nm, typ) |
28620
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
27 |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
28 if (strcmp (typ , "txt")) |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
29 image_as_txt (d, nm); |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
30 return; |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
31 endif |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
32 |
20322
03c88436ad8c
Correctly generate figure 15.7 of the Manual.
Rik <rik@octave.org>
parents:
20321
diff
changeset
|
33 set_graphics_toolkit (); |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
34 set_print_size (); |
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
35 hide_output (); |
20316
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20315
diff
changeset
|
36 outfile = fullfile (d, [nm "." typ]); |
7257 | 37 if (strcmp (typ, "png")) |
24462
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23903
diff
changeset
|
38 set (groot, "defaulttextfontname", "*"); |
7257 | 39 endif |
9914
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
40 if (strcmp (typ, "eps")) |
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
41 d_typ = "-depsc2"; |
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
42 else |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
43 d_typ = ["-d", typ]; |
9914
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
44 endif |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
9298
diff
changeset
|
45 |
28620
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
46 if (strcmp (nm, "plot")) |
6888 | 47 x = -10:0.1:10; |
48 plot (x, sin (x)); | |
17166
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
49 xlabel ("x"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
50 ylabel ("sin (x)"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
51 title ("Simple 2-D Plot"); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19791
diff
changeset
|
52 print (outfile, d_typ); |
6888 | 53 elseif (strcmp (nm, "hist")) |
19791
b254a2e0859c
plotimages.m: Produce the same hist plot for documentation each time (bug #44263)
Rik <rik@octave.org>
parents:
19717
diff
changeset
|
54 randn ("state", 1); |
6888 | 55 hist (randn (10000, 1), 30); |
17166
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
56 xlabel ("Value"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
57 ylabel ("Count"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
58 title ("Histogram of 10,000 normally distributed random numbers"); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19791
diff
changeset
|
59 print (outfile, d_typ); |
6888 | 60 elseif (strcmp (nm, "errorbar")) |
11033
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
9914
diff
changeset
|
61 rand ("state", 2); |
6888 | 62 x = 0:0.1:10; |
63 y = sin (x); | |
21155
8b1e030d3d4f
doc: Correct example errobar code and plot (bug #46972).
Rik <rik@octave.org>
parents:
19791
diff
changeset
|
64 lerr = 0.1 .* rand (size (x)); |
8b1e030d3d4f
doc: Correct example errobar code and plot (bug #46972).
Rik <rik@octave.org>
parents:
19791
diff
changeset
|
65 uerr = 0.1 .* rand (size (x)); |
8b1e030d3d4f
doc: Correct example errobar code and plot (bug #46972).
Rik <rik@octave.org>
parents:
19791
diff
changeset
|
66 errorbar (x, y, lerr, uerr); |
11033
d9c8916bb9dd
Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents:
9914
diff
changeset
|
67 axis ([0, 10, -1.1, 1.1]); |
17166
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
68 xlabel ("x"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
69 ylabel ("sin (x)"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
70 title ("Errorbar plot of sin (x)"); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19791
diff
changeset
|
71 print (outfile, d_typ); |
6888 | 72 elseif (strcmp (nm, "polar")) |
73 polar (0:0.1:10*pi, 0:0.1:10*pi); | |
17166
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
74 title ("Example polar plot from 0 to 10*pi"); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19791
diff
changeset
|
75 print (outfile, d_typ); |
6888 | 76 elseif (strcmp (nm, "mesh")) |
77 tx = ty = linspace (-8, 8, 41)'; | |
78 [xx, yy] = meshgrid (tx, ty); | |
79 r = sqrt (xx .^ 2 + yy .^ 2) + eps; | |
80 tz = sin (r) ./ r; | |
81 mesh (tx, ty, tz); | |
17166
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
82 xlabel ("tx"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
83 ylabel ("ty"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
84 zlabel ("tz"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
85 title ("3-D Sombrero plot"); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19791
diff
changeset
|
86 print (outfile, d_typ); |
6888 | 87 elseif (strcmp (nm, "plot3")) |
88 t = 0:0.1:10*pi; | |
89 r = linspace (0, 1, numel (t)); | |
90 z = linspace (0, 1, numel (t)); | |
20316
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20315
diff
changeset
|
91 plot3 (r.*sin (t), r.*cos (t), z); |
17166
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
92 xlabel ("r.*sin (t)"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
93 ylabel ("r.*cos (t)"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
94 zlabel ("z"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
95 title ("plot3 display of 3-D helix"); |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19791
diff
changeset
|
96 print (outfile, d_typ); |
7189 | 97 elseif (strcmp (nm, "extended")) |
98 x = 0:0.01:3; | |
20315
b9d4ccf4291c
Use FLTK for creating plots for Manual.
Michael D. Godfrey <michaeldgodfrey@gmail.com>
parents:
20307
diff
changeset
|
99 plot (x, erf (x)); |
7189 | 100 hold on; |
20315
b9d4ccf4291c
Use FLTK for creating plots for Manual.
Michael D. Godfrey <michaeldgodfrey@gmail.com>
parents:
20307
diff
changeset
|
101 plot (x, x, "r"); |
17166
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
102 axis ([0, 3, 0, 1]); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
103 xlabel ("x"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
104 ylabel ("erf (x)"); |
0e34c475c956
plotimages.m: Add axis labels and titles to plots in Manual.
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16994
diff
changeset
|
105 title ("erf (x) with text annotation"); |
20337
8e056730f27c
doc: Fix building of Manual plot 15.7 under gnuplot.
Rik <rik@octave.org>
parents:
20335
diff
changeset
|
106 if (strcmp (typ, "pdf") && ! strcmp (graphics_toolkit, "gnuplot")) |
8e056730f27c
doc: Fix building of Manual plot 15.7 under gnuplot.
Rik <rik@octave.org>
parents:
20335
diff
changeset
|
107 text (0.65, 0.6175, ['$\displaystyle\leftarrow x = {2\over\sqrt{\pi}}'... |
23903
a08e277f985f
doc: Update production of figure 15.7 (--pdflatexstandalone usage) in the manual (bug #32617).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
108 '\int_{0}^{x}e^{-t^2} dt = 0.6175$'], |
a08e277f985f
doc: Update production of figure 15.7 (--pdflatexstandalone usage) in the manual (bug #32617).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
109 "interpreter", "latex"); |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
110 ## Be very careful about modifying this. pdflatex expects to be in |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
111 ## the same directory as the file it is operating on. |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20377
diff
changeset
|
112 cd (make_absolute_filename (d)); |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
113 print ([nm ".pdf"], "-dpdflatexstandalone"); |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
114 [status, output] = system (["pdflatex " nm]); |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
115 if (status) |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
116 error ("plotimages: Failed to run pdflatex on <extended.pdf>"); |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
117 endif |
20315
b9d4ccf4291c
Use FLTK for creating plots for Manual.
Michael D. Godfrey <michaeldgodfrey@gmail.com>
parents:
20307
diff
changeset
|
118 delete ([nm ".aux"], [nm "-inc.pdf"], [nm ".log"], [nm ".tex"]); |
b9d4ccf4291c
Use FLTK for creating plots for Manual.
Michael D. Godfrey <michaeldgodfrey@gmail.com>
parents:
20307
diff
changeset
|
119 else |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
120 text (0.65, 0.6175, ['\leftarrow x = {2/\surd\pi {\fontsize{16}' ... |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
121 '\int_{\fontsize{8}0}^{\fontsize{8}x}} e^{-t^2} dt} = 0.6175']); |
20321
fc3056b9fac0
write figure to specified output directory
John W. Eaton <jwe@octave.org>
parents:
20316
diff
changeset
|
122 print (outfile, d_typ); |
20315
b9d4ccf4291c
Use FLTK for creating plots for Manual.
Michael D. Godfrey <michaeldgodfrey@gmail.com>
parents:
20307
diff
changeset
|
123 endif |
29451
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
124 elseif (strcmp (nm, "precisiondate")) |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
125 rand ("state", 1); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
126 t = datenum (2020, 1, 1):(1/1440):datenum (2020, 1, 2); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
127 x = -cos (2*pi*t) + rand (size (t)) / 10; |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
128 subplot (1, 2, 1); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
129 plot (t, x); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
130 datetick ("x"); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
131 xlabel ("serial date"); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
132 title ("problem"); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
133 subplot (1, 2, 2); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
134 plot (t - 730485, x); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
135 datetick ("x"); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
136 xlabel ("2000 years off"); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
137 title ("workaround"); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
138 # set wider aspect ratio |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
139 image_size = [8.25, 3.5]; # in inches, 5:2 format |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
140 border = 0; # For postscript use 50/72 |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
141 set (gcf, "papersize", image_size + 2*border); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
142 set (gcf, "paperposition", [border, border, image_size]); |
75ba68c686ab
doc: Document single precision issues with OpenGL graphics toolkits (bug #59418).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
143 print (outfile, d_typ); |
6888 | 144 else |
145 error ("unrecognized plot requested"); | |
146 endif | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
147 hide_output (); |
6888 | 148 endfunction |
149 | |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
150 ## This function no longer sets the graphics toolkit; That is now done |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
151 ## automatically by C++ code which will ordinarily choose 'qt', but might |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
152 ## choose gnuplot on older systems. Only a complete lack of plotting is a |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
153 ## problem. |
20322
03c88436ad8c
Correctly generate figure 15.7 of the Manual.
Rik <rik@octave.org>
parents:
20321
diff
changeset
|
154 function set_graphics_toolkit () |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
155 if (isempty (available_graphics_toolkits ())) |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20322
diff
changeset
|
156 error ("no graphics toolkit available for plotting"); |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
157 elseif (strcmp ("qt", graphics_toolkit ()) |
25428
2b3c3c8c8360
Properly test Qt offscreen printing during manual figures generation.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25054
diff
changeset
|
158 && __have_feature__ ("QT_OFFSCREEN")) |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
159 ## Use qt with QOffscreenSurface for plot |
27847
56d94f86a659
Don't test presence of OSMESA which will always fail (bug #57424)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
160 elseif (! strcmp ("gnuplot", graphics_toolkit ())) |
20885
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20715
diff
changeset
|
161 if (! any (strcmp ("gnuplot", available_graphics_toolkits ()))) |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20715
diff
changeset
|
162 error ("no graphics toolkit available for offscreen plotting"); |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20715
diff
changeset
|
163 else |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20715
diff
changeset
|
164 graphics_toolkit ("gnuplot"); |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20715
diff
changeset
|
165 endif |
20322
03c88436ad8c
Correctly generate figure 15.7 of the Manual.
Rik <rik@octave.org>
parents:
20321
diff
changeset
|
166 endif |
03c88436ad8c
Correctly generate figure 15.7 of the Manual.
Rik <rik@octave.org>
parents:
20321
diff
changeset
|
167 endfunction |
03c88436ad8c
Correctly generate figure 15.7 of the Manual.
Rik <rik@octave.org>
parents:
20321
diff
changeset
|
168 |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
169 function set_print_size () |
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
170 image_size = [5.0, 3.5]; # in inches, 16:9 format |
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
171 border = 0; # For postscript use 50/72 |
24462
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23903
diff
changeset
|
172 set (groot, "defaultfigurepapertype", "<custom>"); |
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23903
diff
changeset
|
173 set (groot, "defaultfigurepaperorientation", "landscape"); |
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23903
diff
changeset
|
174 set (groot, "defaultfigurepapersize", image_size + 2*border); |
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23903
diff
changeset
|
175 set (groot, "defaultfigurepaperposition", [border, border, image_size]); |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
176 endfunction |
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
177 |
20322
03c88436ad8c
Correctly generate figure 15.7 of the Manual.
Rik <rik@octave.org>
parents:
20321
diff
changeset
|
178 ## Use this function before plotting commands and after every call to print |
03c88436ad8c
Correctly generate figure 15.7 of the Manual.
Rik <rik@octave.org>
parents:
20321
diff
changeset
|
179 ## since print() resets output to stdout (unfortunately, gnuplot can't pop |
03c88436ad8c
Correctly generate figure 15.7 of the Manual.
Rik <rik@octave.org>
parents:
20321
diff
changeset
|
180 ## output as it can the terminal type). |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
181 function hide_output () |
20322
03c88436ad8c
Correctly generate figure 15.7 of the Manual.
Rik <rik@octave.org>
parents:
20321
diff
changeset
|
182 hf = figure (1, "visible", "off"); |
6888 | 183 endfunction |
7256 | 184 |
185 ## generate something for the texinfo @image command to process | |
20315
b9d4ccf4291c
Use FLTK for creating plots for Manual.
Michael D. Godfrey <michaeldgodfrey@gmail.com>
parents:
20307
diff
changeset
|
186 function image_as_txt (d, nm) |
20316
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20315
diff
changeset
|
187 fid = fopen (fullfile (d, [nm ".txt"]), "wt"); |
7256 | 188 fputs (fid, "\n"); |
189 fputs (fid, "+---------------------------------+\n"); | |
190 fputs (fid, "| Image unavailable in text mode. |\n"); | |
191 fputs (fid, "+---------------------------------+\n"); | |
192 fclose (fid); | |
193 endfunction |