# HG changeset patch # User Ben Abbott # Date 1370494781 -28800 # Node ID 5cf7369a74cb1389a50dc1d2357f9bffa2bc1b88 # Parent 3ce3579405f8b9ed9efb700d6c1b864569007fd4 Update legend box when the fontsize changes. * scripts/plot/legend.m: Use the legend fontsize property when creating text objects. Update the legend when the fontsize property changes. Modify demo. Bug # 38265. diff -r 3ce3579405f8 -r 5cf7369a74cb scripts/plot/legend.m --- a/scripts/plot/legend.m Thu Jun 06 11:03:22 2013 +0800 +++ b/scripts/plot/legend.m Thu Jun 06 12:59:41 2013 +0800 @@ -593,6 +593,7 @@ axes (hlegend); delete (get (hlegend, "children")); endif + fontsize = get (hlegend, "fontsize"); ## Add text label to the axis first, checking their extents nentries = numel (hplots); texthandle = []; @@ -603,12 +604,12 @@ texthandle = [texthandle, text(0, 0, text_strings{k}, "horizontalalignment", "left", "userdata", hplots(k), - "fontsize", ca_fontsize)]; + "fontsize", fontsize)]; else texthandle = [texthandle, text(0, 0, text_strings{k}, "horizontalalignment", "right", "userdata", hplots(k), - "fontsize", ca_fontsize)]; + "fontsize", fontsize)]; endif units = get (texthandle(end), "units"); unwind_protect @@ -874,7 +875,7 @@ if (addprops) addlistener (hlegend, "edgecolor", @updatelegendtext); addlistener (hlegend, "textcolor", @updatelegendtext); - addlistener (hlegend, "fontsize", @updatelegendtext); + addlistener (hlegend, "fontsize", @updatelegend); addlistener (hlegend, "interpreter", @updatelegendtext); addlistener (hlegend, "location", @updatelegend); addlistener (hlegend, "orientation", @updatelegend); @@ -1066,11 +1067,11 @@ endif endfunction - %!demo %! plot (rand (2)); %! title ('legend called with cellstr and string inputs for labels'); -%! legend ({'foo'}, 'bar'); +%! h = legend ({'foo'}, 'bar'); +%! set (h, 'fontsize', 20) %!demo %! plot (rand (3));