# HG changeset patch # User Ben Abbott # Date 1360079806 18000 # Node ID cddf9103a566d70627f71abdd3a2dfdd3f96321e # Parent 7275cfaddb5e0f8c0a9c83aa5658880cb835b923 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. diff --git a/scripts/plot/legend.m b/scripts/plot/legend.m --- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -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) diff --git a/scripts/plot/private/__go_draw_axes__.m b/scripts/plot/private/__go_draw_axes__.m --- a/scripts/plot/private/__go_draw_axes__.m +++ b/scripts/plot/private/__go_draw_axes__.m @@ -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