# HG changeset patch
# User Michael D. Godfrey <michaeldgodfrey@gmail.com>
# Date 1436397343 -3600
#      Thu Jul 09 00:15:43 2015 +0100
# Node ID ee3df653c90329241667db6fc51ed44382c4b10a
# Parent  9e361ecea8788263ff645209e1ec4cab685a862c
fltk plots for Manual

diff -r 9e361ecea878 -r ee3df653c903 doc/interpreter/plot.txi
--- a/doc/interpreter/plot.txi	Tue Jul 07 22:00:06 2015 -0400
+++ b/doc/interpreter/plot.txi	Thu Jul 09 00:15:43 2015 +0100
@@ -33,7 +33,7 @@
 
 Earlier versions of Octave provided plotting through the use of
 gnuplot.  This capability is still available.  But, a newer plotting
-capability is provided by access to OpenGL@.  Which plotting system
+capability is provided by access to OpenGL.  Which plotting system
 is used is controlled by the @code{graphics_toolkit} function.
 @xref{Graphics Toolkits}.
 
@@ -205,13 +205,14 @@ and linear.  For example,
 
 @example
 polar (0:0.1:10*pi, 0:0.1:10*pi);
+set (gca, 'rtick', [0:10:40]);
 @end example
 
 @noindent
 produces the spiral plot shown in @ref{fig:polar}.
 
 @float Figure,fig:polar
-@center @image{polar,4in}
+@center @image{polar,5in}
 @caption{Polar plot.}
 @end float
 
@@ -914,31 +915,6 @@ width 0.6pt \tabskip=0pt\cr
 @end tex
 @end float
 
-A complete example showing the capabilities of the extended text is
-
-@example
-@group
-x = 0:0.01:3;
-plot (x, erf (x));
-hold on;
-plot (x,x,"r");
-axis ([0, 3, 0, 1]);
-text (0.65, 0.6175, strcat ('\leftarrow x = @{2/\surd\pi',
-' @{\fontsize@{16@}\int_@{\fontsize@{8@}0@}^@{\fontsize@{8@}x@}@}',
-' e^@{-t^2@} dt@} = 0.6175'))
-@end group
-@end example
-
-@ifnotinfo
-@noindent
-The result of which can be seen in @ref{fig:extendedtext}
-
-@float Figure,fig:extendedtext
-@center @image{extended,4in}
-@caption{Example of inclusion of text with the @TeX{} interpreter}
-@end float
-@end ifnotinfo
-
 @node Printing and Saving Plots
 @subsection Printing and Saving Plots
 @cindex plotting, saving and printing plots
@@ -963,12 +939,50 @@ print -deps foo.eps
 saves the current figure to an encapsulated PostScript file called
 @file{foo.eps}.
 
-The different graphic toolkits have different print capabilities.  In
-particular, the OpenGL based toolkits such as @code{fltk} do not support
-the @qcode{"interpreter"} property of text objects.  This means special
+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.
-Switch graphics toolkits for printing if this is a concern.
+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.
+
+A complete example showing the capabilities of text printing using the
+@code{-dpdflatexstandalone} option is:
+
+@example
+@group
+x = 0:0.01:3;
+fig7=figure();
+plot (x,erf(x));
+hold on;
+plot (x,x,"r");
+axis ([0, 3, 0, 1]);
+text (0.65, 0.6175, strcat ('$\leftarrow x = @{2\over@{\sqrt@{\pi@}@}@}',
+        '\int_@{0@}^@{x@}@}e^@{-t^2@} dt = 0.6175$'));
+xlabel ("x");
+ylabel ("erf (x)");
+title ("erf (x) with text annotation");
+figure (fig7,"visible","off")
+print (fig7, 'plot15_7.pdf', '-dpdflatexstandalone')
+system ('pdflatex plot15_7');
+system ('acroread plot15_7.pdf&');
+@end group
+@end example
+
+@ifnotinfo
+@noindent
+The result of this example can be seen in @ref{fig:extendedtext}
+
+@float Figure,fig:extendedtext
+@center @image{extended,5in}
+@caption{Example of inclusion of text with use of @code{-dpdflatexstandalone}}
+@end float
+@end ifnotinfo
+
+
 
 @DOCSTRING(print)
 
diff -r 9e361ecea878 -r ee3df653c903 doc/interpreter/plotimages.m
--- a/doc/interpreter/plotimages.m	Tue Jul 07 22:00:06 2015 -0400
+++ b/doc/interpreter/plotimages.m	Thu Jul 09 00:15:43 2015 +0100
@@ -17,7 +17,14 @@
 ## <http://www.gnu.org/licenses/>.
 
 function plotimages (d, nm, typ)
-  graphics_toolkit ("gnuplot");
+  tkind = strcmp ("fltk", available_graphics_toolkits ());
+  if (any (tkind))
+    graphics_toolkit ("fltk");
+  elseif (any (strcmp ("gnuplot", available_graphics_toolkits ())))
+    graphics_toolkit ("gnuplot");
+  else
+    error ("no valid graphics toolkit found");
+  endif
   set_print_size ();
   hide_output ();
   outfile = fullfile (d, strcat (nm, ".", typ));
@@ -30,8 +37,8 @@ function plotimages (d, nm, typ)
     d_typ = ["-d", typ];
   endif
 
-  if (strcmp(typ , "txt"))
-    image_as_txt(d, nm);
+  if (strcmp (typ , "txt"))
+    image_as_txt (d, nm);
   elseif (strcmp (nm, "plot"))
     x = -10:0.1:10;
     plot (x, sin (x));
@@ -60,6 +67,7 @@ function plotimages (d, nm, typ)
     print (outfile, d_typ);
   elseif (strcmp (nm, "polar"))
     polar (0:0.1:10*pi, 0:0.1:10*pi);
+    set (gca, 'rtick', [0:10:40]);
     title ("Example polar plot from 0 to 10*pi");
     print (outfile, d_typ);
   elseif (strcmp (nm, "mesh"))
@@ -77,7 +85,7 @@ function plotimages (d, nm, typ)
     t = 0:0.1:10*pi;
     r = linspace (0, 1, numel (t));
     z = linspace (0, 1, numel (t));
-    plot3 (r.*sin(t), r.*cos(t), z);
+    plot3 (r.*sin (t), r.*cos (t), z);
     xlabel ("r.*sin (t)");
     ylabel ("r.*cos (t)");
     zlabel ("z");
@@ -85,16 +93,23 @@ function plotimages (d, nm, typ)
     print (outfile, d_typ);
   elseif (strcmp (nm, "extended"))
     x = 0:0.01:3;
-    plot (x,erf(x));
+    plot (x, erf (x));
     hold on;
-    plot (x,x,"r");
+    plot (x, x, "r");
     axis ([0, 3, 0, 1]);
-    text (0.65, 0.6175, ['\leftarrow x = {2/\surd\pi {\fontsize{16}' ...
-          '\int_{\fontsize{8}0}^{\fontsize{8}x}} e^{-t^2} dt} = 0.6175']);
     xlabel ("x");
     ylabel ("erf (x)");
     title ("erf (x) with text annotation");
-    print (outfile, d_typ);
+    if ( strcmp (typ, "pdf") && strcmp (graphics_toolkit (), "fltk"))
+      text (0.65, 0.6175, strcat ('$\leftarrow x = {2\over{\sqrt{\pi}}}',
+            '\int_{0}^{x}e^{-t^2} dt = 0.6175$'));
+      print (outfile, '-dpdflatexstandalone');
+      system (['pdflatex ' nm '']);
+    else
+      text (0.65, 0.6175, ['\leftarrow x = {2/\surd\pi {\fontsize{16}' ...
+            '\int_{\fontsize{8}0}^{\fontsize{8}x}} e^{-t^2} dt} = 0.6175']);
+      print (outfile, d_typ);
+    endif
   else
     error ("unrecognized plot requested");
   endif
