changeset 16002:cddf9103a566

Fix legend bugs (#38263, #38265). * scripts/plot/legend.m: Add listener for the legend hggroup "fontsize" property, and add "fontsize" to the updated properties. * scripts/plot/private/__go_draw_axes__.m: Limited supprt for changing the color of the legend's text labels.
author Ben Abbott <bpabbott@mac.com>
date Tue, 05 Feb 2013 10:56:46 -0500
parents 7275cfaddb5e
children 1045790f9be4
files scripts/plot/legend.m scripts/plot/private/__go_draw_axes__.m
diffstat 2 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/legend.m	Wed Feb 06 09:54:16 2013 -0500
+++ b/scripts/plot/legend.m	Tue Feb 05 10:56:46 2013 -0500
@@ -874,6 +874,7 @@
         if (addprops)
           addlistener (hlegend, "edgecolor", @updatelegendtext);
           addlistener (hlegend, "textcolor", @updatelegendtext);
+          addlistener (hlegend, "fontsize", @updatelegendtext);
           addlistener (hlegend, "interpreter", @updatelegendtext);
           addlistener (hlegend, "location", @updatelegend);
           addlistener (hlegend, "orientation", @updatelegend);
@@ -915,7 +916,10 @@
   text_kids = findobj (kids, "-property", "interpreter", "type", "text");
   interpreter = get (h, "interpreter");
   textcolor = get (h, "textcolor");
-  set (text_kids, "interpreter", interpreter, "color", textcolor);
+  fontsize = get (h, "fontsize");
+  set (text_kids, "interpreter", interpreter,
+                  "fontsize", fontsize,
+                  "color", textcolor);
 endfunction
 
 function hideshowlegend (h, d, ca, pos1, pos2)
--- a/scripts/plot/private/__go_draw_axes__.m	Wed Feb 06 09:54:16 2013 -0500
+++ b/scripts/plot/private/__go_draw_axes__.m	Tue Feb 05 10:56:46 2013 -0500
@@ -1591,7 +1591,19 @@
       else
         fontspec = "";
       endif
-      colorspec = get_text_colorspec (hlgnd.textcolor, mono);
+      textcolors = get (findobj (hlgnd.children, "type", "text"), "color");
+      if (iscell (textcolors))
+        textcolors = cell2mat (textcolors);
+        textcolors = unique (textcolors, "rows");
+      endif
+      if (rows (textcolors) > 1)
+        ## Gnuplot is unable to assign arbitrary colors to each text entry
+        ## for the key/legend.  But, the text color can be set to match the
+        ## color of the plot object.
+        colorspec = "textcolor variable";
+      else
+        colorspec = get_text_colorspec (textcolors, mono);
+      endif
       fprintf (plot_stream, "set key %s %s;\nset key %s %s %s %s %s;\n",
                inout, pos, box, reverse, horzvert, fontspec, colorspec);
     else