# HG changeset patch # User Ben Abbott # Date 1224027832 14400 # Node ID 1c62c7ab79dc82cb458b7a5ef2f24526a67ea826 # Parent f74cb5e3a6c1b8b40d34c8aeb03df19556db202f x/y/z-ticklabels respect axis font properties. diff -r f74cb5e3a6c1 -r 1c62c7ab79dc scripts/ChangeLog --- a/scripts/ChangeLog Tue Oct 14 14:59:09 2008 -0400 +++ b/scripts/ChangeLog Tue Oct 14 19:43:52 2008 -0400 @@ -1,3 +1,8 @@ +2008-10-14 Ben Abbott + + * plot/newplot.m: Perserve particular axes properties when replacing plot. + * plot/__go_draw_axes__.m: Tick labels respect axes font properties. + 2008-10-14 Daniel J. Sebald * plot/__go_draw_axes__.m: Send binary data to gnuplot. diff -r f74cb5e3a6c1 -r 1c62c7ab79dc scripts/plot/__go_draw_axes__.m --- a/scripts/plot/__go_draw_axes__.m Tue Oct 14 14:59:09 2008 -0400 +++ b/scripts/plot/__go_draw_axes__.m Tue Oct 14 19:43:52 2008 -0400 @@ -1362,51 +1362,64 @@ endfunction function do_tics (obj, plot_stream, ymirror, mono) + [fontname, fontsize] = get_fontname_and_size (obj); if (strcmpi (obj.xaxislocation, "top")) do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, obj.xcolor, "x2", plot_stream, true, mono, "border", - obj.tickdir); + obj.tickdir, fontname, fontsize); do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, - obj.xcolor, "x", plot_stream, true, mono, "border", ""); + obj.xcolor, "x", plot_stream, true, mono, "border", + "", fontname, fontsize); elseif (strcmpi (obj.xaxislocation, "zero")) do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono, "axis", - obj.tickdir); + obj.tickdir, fontname, fontsize); do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, - obj.xcolor, "x2", plot_stream, true, mono, "axis", ""); + obj.xcolor, "x2", plot_stream, true, mono, "axis", + "", fontname, fontsize); else do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono, "border", - obj.tickdir); + obj.tickdir, fontname, fontsize); do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, - obj.xcolor, "x2", plot_stream, true, mono, "border", ""); + obj.xcolor, "x2", plot_stream, true, mono, "border", + "", fontname, fontsize); endif if (strcmpi (obj.yaxislocation, "right")) do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, obj.ycolor, "y2", plot_stream, ymirror, mono, "border", - obj.tickdir); + obj.tickdir, fontname, fontsize); do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, - obj.ycolor, "y", plot_stream, ymirror, mono, "border", ""); + obj.ycolor, "y", plot_stream, ymirror, mono, "border", + "", fontname, fontsize); elseif (strcmpi (obj.xaxislocation, "zero")) do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono, "axis", - obj.tickdir); + obj.tickdir, fontname, fontsize); do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, - obj.ycolor, "y2", plot_stream, ymirror, mono, "axis", ""); + obj.ycolor, "y2", plot_stream, ymirror, mono, "axis", + "", fontname, fontsize); else do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono, "border", - obj.tickdir); + obj.tickdir, fontname, fontsize); do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, - obj.ycolor, "y2", plot_stream, ymirror, mono, "border", ""); + obj.ycolor, "y2", plot_stream, ymirror, mono, "border", + "", fontname, fontsize); endif do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel, obj.zcolor, "z", plot_stream, true, mono, "border", - obj.tickdir); + obj.tickdir, fontname, fontsize); endfunction function do_tics_1 (ticmode, tics, labelmode, labels, color, ax, - plot_stream, mirror, mono, axispos, tickdir) + plot_stream, mirror, mono, axispos, tickdir, + fontname, fontsize) + if (strcmp (fontname, "*")) + fontspec = ""; + else + fontspec = sprintf ("font \"%s,%d\"", fontname, fontsize); + endif colorspec = get_text_colorspec (color, mono); if (strcmpi (ticmode, "manual") || strcmpi (labelmode, "manual")) if (isempty (tics)) @@ -1437,7 +1450,7 @@ k = 1; endif endfor - fprintf (plot_stream, ") %s;\n", colorspec); + fprintf (plot_stream, ") %s %s;\n", colorspec, fontspec); else error ("unsupported type of ticklabel"); endif @@ -1451,16 +1464,16 @@ axispos); endif fprintf (plot_stream, " %.15g,", tics(1:end-1)); - fprintf (plot_stream, " %.15g);\n", tics(end)); + fprintf (plot_stream, " %.15g) %s;\n", tics(end), fontspec); endif else fprintf (plot_stream, "set format %s \"%%g\";\n", ax); if (mirror) - fprintf (plot_stream, "set %stics %s %s mirror %s;\n", ax, - axispos, tickdir, colorspec); + fprintf (plot_stream, "set %stics %s %s mirror %s %s;\n", ax, + axispos, tickdir, colorspec, fontspec); else - fprintf (plot_stream, "set %stics %s %s nomirror %s;\n", ax, - tickdir, axispos, colorspec); + fprintf (plot_stream, "set %stics %s %s nomirror %s %s;\n", ax, + tickdir, axispos, colorspec, fontspec); endif endif endfunction diff -r f74cb5e3a6c1 -r 1c62c7ab79dc scripts/plot/newplot.m --- a/scripts/plot/newplot.m Tue Oct 14 14:59:09 2008 -0400 +++ b/scripts/plot/newplot.m Tue Oct 14 19:43:52 2008 -0400 @@ -44,7 +44,17 @@ case "add" case "replacechildren" case "replace" + ## Preserve certain axes properties + fontprops = {"fontangle", get(ca, "fontangle"), ... + "fontname", get(ca, "fontname"), ... + "fontsize", get(ca, "fontsize"), ... + "fontunits", get(ca, "fontunits"), ... + "fontweight", get(ca, "fontweight"), ... + "position", get(ca, "position"), ... + "outerposition", get(ca, "outerposition"), ... + "activepositionproperty", get(ca, "activepositionproperty")}; __go_axes_init__ (ca, "replace"); + set (ca, fontprops{:}); __request_drawnow__ (); otherwise error ("newplot: unrecognized nextplot property for current axes");