changeset 24139:5d2d0e570e46

print.m: fake grid transparency with gray color (bug #49705) * print.m: for opengl toolkits and formats other than "svg", when axes (minor)gridcolormode is "auto" switch (minor)gridcolor to gray for printing.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Thu, 12 Oct 2017 23:17:25 +0200
parents e201dc969e24
children 0b7662d8bd02
files scripts/plot/util/print.m
diffstat 1 files changed, 33 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/print.m	Thu Oct 12 20:48:32 2017 +0200
+++ b/scripts/plot/util/print.m	Thu Oct 12 23:17:25 2017 +0200
@@ -357,6 +357,7 @@
   unwind_protect
 
     ## Modify properties as specified by options
+    tk = get (opts.figure, "__graphics_toolkit__");
     props = [];
     nfig = 0;
 
@@ -378,7 +379,7 @@
     ## print() requires axes units = "normalized"
     hax = findall (opts.figure, "-depth", 1, "type", "axes", ...
       "-not", "units", "normalized");
-    for n = 1:numel(hax)
+    for n = 1:numel (hax)
       props(end+1).h = hax(n);
       props(end).name = "units";
       props(end).value = {get(hax(n), "units")};
@@ -386,6 +387,36 @@
       nfig += 1;
     endfor
 
+    ## FIXME: line transparency is only handled for svg output when
+    ## using gl2ps. For other formats, switch grid lines to light gray
+    ## so that the image output approximately matches on-screen experience.
+    hax = findall (opts.figure, "type", "axes");
+    if (! strcmp (tk, "gnuplot") && ! strcmp (opts.devopt, "svg"))
+      for n = 1:numel (hax)
+        if (strcmp (get (hax(n), "gridcolormode"), "auto"))
+          props(end+1).h = hax(n);
+          props(end).name = "gridcolormode";
+          props(end).value = {"auto"};
+          props(end+1).h = hax(n);
+          props(end).name = "gridcolor";
+          props(end).value = {get(hax(n), "gridcolor")};
+          set (hax(n), "gridcolor", [0.85 0.85 0.85]);
+          nfig += 2;
+        endif
+
+        if (strcmp (get (hax(n), "minorgridcolormode"), "auto"))
+          props(end+1).h = hax(n);
+          props(end).name = "minorgridcolormode";
+          props(end).value = {"auto"};
+          props(end+1).h = hax(n);
+          props(end).name = "minorgridcolor";
+          props(end).value = {get(hax(n), "minorgridcolor")};
+          set (hax(n), "minorgridcolor", [0.75 0.75 0.75]);
+          nfig += 2;
+        endif
+      endfor
+    endif
+    
     ## print() requires figure units to be "pixels"
     props(end+1).h = opts.figure;
     props(end).name = "units";
@@ -514,7 +545,7 @@
     endif
 
     ## call the graphics toolkit print script
-    switch (get (opts.figure, "__graphics_toolkit__"))
+    switch (tk)
       case "gnuplot"
         opts = __gnuplot_print__ (opts);
       otherwise