changeset 20357:03c88436ad8c

Correctly generate figure 15.7 of the Manual. * plot.txi: Improve the wording discussing the standalone example of 15.7. * plotimages.m (set_graphics_toolkit): New subfunction to choose a graphics toolkit with a preference for OpenGL based toolkits. * plotimages.m (hide_output): Use figure (..., "visible", "off") to stop window flicker during generation of images.
author Rik <rik@octave.org>
date Fri, 10 Jul 2015 21:10:42 -0700
parents fc3056b9fac0
children 820c5a4dd0ab
files doc/interpreter/plot.txi doc/interpreter/plotimages.m
diffstat 2 files changed, 28 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/plot.txi	Fri Jul 10 17:22:50 2015 -0400
+++ b/doc/interpreter/plot.txi	Fri Jul 10 21:10:42 2015 -0700
@@ -939,17 +939,18 @@
 saves the current figure to an encapsulated PostScript file called
 @file{foo.eps}.
 
-The current graphic toolkits have differing print capabilities.  In particular,
+The current graphic toolkits produce very similar graphic displays but differ
+in their capability to display text and in print capabilities.  In particular,
 the OpenGL based toolkits such as @code{fltk} and @code{qt} do not support the
 @qcode{"interpreter"} property of text objects.  This means that when using
 OpenGL toolkits special symbols drawn with the @qcode{"tex"} interpreter will
 appear correctly on-screen but will be rendered with interpreter @qcode{"none"}
 when printing unless one of the @qcode{standalone} (see below) modes is used.
 These modes provide access to the pdflatex processor and therefore allow full
-use of LaTeX commands.
+use of @LaTeX{} commands.
 
 A complete example showing the capabilities of text printing using the
-@code{-dpdflatexstandalone} option is
+@code{-dpdflatexstandalone} option is:
 
 @example
 @group
@@ -964,17 +965,17 @@
 xlabel ("x");
 ylabel ("erf (x)");
 title ("erf (x) with text annotation");
-set (hf, "visible", "off")
-print (hf, "plot15_7.pdf", "-dpdflatexstandalone")
-set (hf, "visible", "on")
+set (hf, "visible", "off");
+print (hf, "plot15_7.pdf", "-dpdflatexstandalone");
+set (hf, "visible", "on");
 system ("pdflatex plot15_7");
-system ("acroread plot15_7.pdf &");
+open ("plot15_7.pdf");
 @end group
 @end example
 
 @ifnotinfo
 @noindent
-The result of which can be seen in @ref{fig:extendedtext}
+The result of this example can be seen in @ref{fig:extendedtext}
 
 @float Figure,fig:extendedtext
 @center @image{extended,4in}
--- a/doc/interpreter/plotimages.m	Fri Jul 10 17:22:50 2015 -0400
+++ b/doc/interpreter/plotimages.m	Fri Jul 10 21:10:42 2015 -0700
@@ -17,7 +17,7 @@
 ## <http://www.gnu.org/licenses/>.
 
 function plotimages (d, nm, typ)
-  graphics_toolkit ("qt");
+  set_graphics_toolkit ();
   set_print_size ();
   hide_output ();
   outfile = fullfile (d, [nm "." typ]);
@@ -113,6 +113,20 @@
   hide_output ();
 endfunction
 
+## Choose a toolkit with a preference for OpenGL renderers
+function set_graphics_toolkit ()
+  avl_tk = available_graphics_toolkits ();
+  if (any (strcmp ("qt", avl_tk)))
+    graphics_toolkit ("qt");
+  elseif (any (strcmp ("fltk", avl_tk)))
+    graphics_toolkit ("fltk");
+  elseif (any (strcmp ("gnuplot", avl_tk)))
+    graphics_toolkit ("gnuplot");
+  else
+    error ("no valid graphics toolkit found");
+  endif
+endfunction
+
 function set_print_size ()
   image_size = [5.0, 3.5]; # in inches, 16:9 format
   border = 0;              # For postscript use 50/72
@@ -122,12 +136,11 @@
   set (0, "defaultfigurepaperposition", [border, border, image_size]);
 endfunction
 
-## Use this function before plotting commands and after every call to
-## print since print() resets output to stdout (unfortunately, gnuplot
-## can't pop output as it can the terminal type).
+## Use this function before plotting commands and after every call to print
+## since print() resets output to stdout (unfortunately, gnuplot can't pop
+## output as it can the terminal type).
 function hide_output ()
-  hf = figure (1);
-  set (hf, "visible", "off");
+  hf = figure (1, "visible", "off");
 endfunction
 
 ## generate something for the texinfo @image command to process