# HG changeset patch # User Ben Abbott # Date 1293661581 18000 # Node ID 00b0aa8d539e3d23a6a4d20827c07a5e4b7ec219 # Parent 3cae59b4c0f7fc31cf54d103d32952ae6a9a1994 __go_draw_axes__.m: Enable vertical alignment of text objects for gnuplot. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2010-12-29 Ben Abbott + + * plot/__go_draw_axes__.m: Enable vertical alignment of text objects for + gnuplot. + 2010-12-28 Ben Abbott * plot/private/__plt__.m: Fix to allow inline legend keys. Bug 31991. diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m --- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -1233,6 +1233,7 @@ fontspec = create_fontspec (f, s, gnuplot_term); lpos = obj.position; halign = obj.horizontalalignment; + valign = obj.verticalalignment; angle = obj.rotation; units = obj.units; color = obj.color; @@ -1249,17 +1250,35 @@ colorspec = get_text_colorspec (color, mono); endif + switch valign + ## Text offset in characters. This relies on gnuplot for font metrics. + case "top" + dy = -0.5; + case "cap" + dy = -0.5; + case "middle" + dy = 0; + case "baseline" + dy = 0.5; + case "bottom" + dy = 0.5; + endswitch + ## Gnuplot's Character units are different for x/y and vary with fontsize. The aspect ratio + ## of 1:2.5 was determined by experiment. + dx_and_dy = [(-dy * sind (angle)), (dy * cosd(angle))] .* [2.5 1]; + if (nd == 3) + ## This produces the desired vertical alignment in 3D. fprintf (plot_stream, - "set label \"%s\" at %s %.15g,%.15g,%.15g %s rotate by %f %s %s front %s;\n", + "set label \"%s\" at %s %.15g,%.15g,%.15g %s rotate by %f offset character %f,%f %s %s front %s;\n", undo_string_escapes (label), units, lpos(1), - lpos(2), lpos(3), halign, angle, fontspec, + lpos(2), lpos(3), halign, angle, dx_and_dy, fontspec, __do_enhanced_option__ (enhanced, obj), colorspec); else fprintf (plot_stream, - "set label \"%s\" at %s %.15g,%.15g %s rotate by %f %s %s front %s;\n", + "set label \"%s\" at %s %.15g,%.15g %s rotate by %f offset character %f,%f %s %s front %s;\n", undo_string_escapes (label), units, - lpos(1), lpos(2), halign, angle, fontspec, + lpos(1), lpos(2), halign, angle, dx_and_dy, fontspec, __do_enhanced_option__ (enhanced, obj), colorspec); endif