changeset 20964:6ac3d299c5ad

Add support for cairo based gnuplot terminals: "cairolatex", "epscairo", "epscairolatex", "epscairolatexstandalone", "pdfcairolatex", and "pdfcairolatexstandalone" (Part of Bug #44187). * __gnuplot_draw__.m: Add "cairolatex" & "epslatex" to terminals_with_size. * print.m: Include the gnuplot cairo based devices to the doc-string. * __gnuplot_print__.m: Add support for gnuplot terminal "epscairo". Also add support for gnuplot's LaTeX enhanced cairo terminals, including the standalonoe variants. When "-debug" is passed to print(), report on the expanded gnuplot terminal.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Tue, 22 Dec 2015 22:30:40 -0500
parents 3aa293be0e8d
children 93a48264f402
files scripts/plot/util/__gnuplot_drawnow__.m scripts/plot/util/print.m scripts/plot/util/private/__gnuplot_print__.m
diffstat 3 files changed, 48 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/__gnuplot_drawnow__.m	Tue Dec 22 10:29:22 2015 -0800
+++ b/scripts/plot/util/__gnuplot_drawnow__.m	Tue Dec 22 22:30:40 2015 -0500
@@ -189,10 +189,11 @@
           gnuplot_size = gnuplot_size / 72;
         endif
         if (all (gnuplot_size > 0))
-          terminals_with_size = {"canvas", "emf", "epslatex", "fig", ...
-                                 "gif", "jpeg", "latex", "pbm", "pdf", ...
-                                 "pdfcairo", "postscript", "png", ...
-                                 "pngcairo", "pstex", "pslatex", "svg", "tikz"};
+          terminals_with_size = {"canvas", "cairolatex", "emf", "epscairo", ...
+                                 "epslatex", "fig", "gif", "jpeg", "latex", ...
+                                 "pbm", "pdf", "pdfcairo", "postscript", ...
+                                 "png", "pngcairo", "pstex", "pslatex", ...
+                                 "svg", "tikz"};
           if (__gnuplot_has_feature__ ("windows_figure_position"))
             terminals_with_size{end+1} = "windows";
           endif
--- a/scripts/plot/util/print.m	Tue Dec 22 10:29:22 2015 -0800
+++ b/scripts/plot/util/print.m	Tue Dec 22 22:30:40 2015 -0500
@@ -125,6 +125,20 @@
 ## braces).  The @samp{pdflatex} device, and any of the @samp{standalone}
 ## formats, are not available with the Gnuplot toolkit.
 ##
+##   @item epscairo
+##   @itemx pdfcairo
+##   @itemx epscairolatex
+##   @itemx pdfcairolatex
+##   @itemx epscairolatexstandalone
+##   @itemx pdfcairolatexstandalone
+##     Generate Cairo based output when using the Gnuplot graphics toolkit.
+## The @samp{epscairo} and @samp{pdfcairo} devices are synonymous with
+## the @samp{epsc} device. The @LaTeX{} variants generate a @LaTeX{} file,
+## @file{@var{filename}.tex}, for the text portions of a plot, and an image
+## file, @file{@var{filename}.(eps|pdf)}, for the graph portion of the plot.
+## The @samp{standalone} variants behave as described for
+## @samp{epslatexstandalone} above.
+##
 ##   @item tikz
 ##     Generate a @LaTeX{} file using PGF/TikZ@.  For the FLTK toolkit
 ## the result is PGF.
--- a/scripts/plot/util/private/__gnuplot_print__.m	Tue Dec 22 10:29:22 2015 -0800
+++ b/scripts/plot/util/private/__gnuplot_print__.m	Tue Dec 22 22:30:40 2015 -0500
@@ -87,19 +87,16 @@
                "invalid suffix '%s' for device '%s'.",
                ext, lower (opts.devopt));
       endif
-
-      if (strfind (opts.devopt, "standalone"))
-        term = sprintf ("%s ",
-                        strrep (opts.devopt, "standalone", " standalone"));
-      else
-        term = sprintf ("%s ", opts.devopt);
-      endif
       if (__gnuplot_has_feature__ ("epslatex_implies_eps_filesuffix"))
         suffix = "tex";
       else
         ## Gnuplot 4.0 wants a ".eps" suffix.
         suffix = "eps";
       endif
+      if (strfind (opts.devopt, "standalone"))
+        gp_opts = sprintf ("standalone %s", gp_opts);
+        term = strrep (opts.devopt, "standalone", "");
+      endif
       local_drawnow ([term " " gp_opts],
                      [name "." suffix], opts);
     case "tikz"
@@ -114,9 +111,25 @@
       local_drawnow (["svg dynamic " gp_opts], opts.name, opts);
     case {"aifm", "corel", "eepic", "emf", "fig"}
       local_drawnow ([opts.devopt " " gp_opts], opts.name, opts);
-    case {"pdfcairo", "pngcairo"}
-      if (__gnuplot_has_terminal__ (opts.devopt))
-        local_drawnow ([opts.devopt " " gp_opts], opts.name, opts);
+    case {"cairolatex", "epscairo", "epscairolatex", ...
+          "epscairolatexstandalone", "pdfcairo", "pdfcairolatex", ...
+          "pdfcairolatexstandalone", "pngcairo"}
+      term = opts.devopt;
+      if (strfind (term, "standalone"))
+        ## TODO: Specifying the size of the figure and page are not yet
+        ## supported. Specifying the font size also does not work.
+        gp_opts = sprintf ("standalone %s", gp_opts);
+        term = strrep (term, "standalone", "");
+      endif
+      if (strfind (term, "epscairolatex"))
+        gp_opts = sprintf ("eps %s", gp_opts);
+        term = strrep (term, "epscairolatex", "cairolatex");
+      elseif (strfind (term, "pdfcairolatex"))
+        gp_opts = sprintf ("pdf %s", gp_opts);
+        term = strrep (term, "pdfcairolatex", "cairolatex");
+      endif
+      if (__gnuplot_has_terminal__ (term))
+        local_drawnow ([term " " gp_opts], opts.name, opts);
       else
         error (sprintf ("print:no%soutput", opts.devopt),
                "print.m: '%s' output is not available for gnuplot-%s",
@@ -199,6 +212,9 @@
   else
     drawnow (term, file, mono, opts.debug_file);
   endif
+  if (opts.debug)
+    fprintf ("Expanded gnuplot terminal = '%s'\n", term)
+  endif
 endfunction
 
 function f = font_spec (opts, varargin)
@@ -247,7 +263,9 @@
       elseif (! isempty (opts.fontsize))
         f = sprintf ('font ",%d"', opts.fontsize);
       endif
-    case {"pdfcairo", "pngcairo"}
+    case {"cairolatex", "epscairo", "epscairolatex", ...
+          "epscairolatexstandalone", "pdfcairo", "pdfcairolatex", ...
+          "pdfcairolatexstandalone", "pngcairo"}
       if (! isempty (opts.font) && ! isempty (opts.fontsize))
         f = sprintf ('font "%s,%d"', opts.font, opts.fontsize);
       elseif (! isempty (opts.font))