# HG changeset patch # User Serviscope Minor # Date 1407181772 -3600 # Node ID 04dc55bf71e87f13f46482ba17d949c2db5f027f # Parent 05a7c6026df0cef4ca2a43be82f498bc8cf026f9 adjust spacing in gnuplot legend when non default font size is used. * scripts/plot/util/private/__go_draw_axes__.m add spacing spec to key definition in __go_draw_axes__ diff -r 05a7c6026df0 -r 04dc55bf71e8 scripts/plot/util/private/__go_draw_axes__.m --- a/scripts/plot/util/private/__go_draw_axes__.m Sun Aug 03 19:40:09 2014 -0400 +++ b/scripts/plot/util/private/__go_draw_axes__.m Mon Aug 04 20:49:32 2014 +0100 @@ -1586,9 +1586,9 @@ endswitch if (__gnuplot_has_feature__ ("key_has_font_properties")) [fontname, fontsize] = get_fontname_and_size (hlgnd); - fontspec = create_fontspec (fontname, fontsize, gnuplot_term); + fontspacespec = [ create_spacingspec(fontname, fontsize, gnuplot_term) create_fontspec(fontname, fontsize, gnuplot_term) ]; else - fontspec = ""; + fontspacespec = ""; endif textcolors = get (findobj (hlgnd.children, "type", "text"), "color"); if (iscell (textcolors)) @@ -1604,7 +1604,7 @@ colorspec = get_text_colorspec (textcolors, mono); endif fprintf (plot_stream, "set key %s %s;\nset key %s %s %s %s %s %s;\n", - inout, pos, box, reverse, horzvert, fontspec, colorspec, + inout, pos, box, reverse, horzvert, fontspacespec, colorspec, __do_enhanced_option__ (enhanced, hlgnd)); else fputs (plot_stream, "unset key;\n"); @@ -1757,6 +1757,18 @@ endif endfunction +function spacing_spec = create_spacingspec(f, s, gp_term) + # The gnuplot default font size is 10, and default spacing is 1.25. + # gnuplot has a concept of a figure global font, and sizes everything + # appropriate to that, including the legend spacing. + # + # This means that if an alternative size is used, gnuplot will use an + # inappropriate spacing in the legend by default. + spc = s / 10 * 1.25; + spacing_spec = sprintf ("spacing %d", spc); + +endfunction + function fontspec = create_fontspec (f, s, gp_term) if (strcmp (f, "*") || strcmp (gp_term, "tikz")) fontspec = sprintf ("font \",%d\"", s);