changeset 8220:4e05ba66ead2

x/y/z-ticklabels respect axis font properties.
author Ben Abbott <bpabbott@mac.com>
date Wed, 15 Oct 2008 14:19:33 -0400
parents f8a885ccd5b4
children 06094fa570a3
files scripts/ChangeLog scripts/plot/__go_draw_axes__.m scripts/plot/newplot.m
diffstat 3 files changed, 54 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Wed Oct 15 11:52:39 2008 -0400
+++ b/scripts/ChangeLog	Wed Oct 15 14:19:33 2008 -0400
@@ -1,3 +1,13 @@
+2008-10-14  Ben Abbott  <bpabbott@mac.com>
+
+	* plot/__go_draw_axes__.m (do_tics_1): New args, fontname and fontsize.
+	Pass fontspec for tic marks to gnuplot.
+	(do_tics): Pass axes fontname and fontsize to do_tics_1.
+	
+	* plot/newplot.m: Perserve fontangle, fontname, fontsize,
+	fontunits, fontweight, position, outerposition, and
+	activepositionproperty axes properties when replacing plot.
+
 2008-10-15  Daniel J. Sebald  <daniel.sebald@ieee.org>
 
 	* plot/__go_draw_axes__.m: Make previous change work for surface
@@ -7,7 +17,7 @@
 
 	* plot/__go_draw_axes__.m: Send binary data to gnuplot.
 
-2008-10-13  Ben Abbott <bpabbott@mac.com>
+2008-10-13  Ben Abbott  <bpabbott@mac.com>
 
 	* plot/__go_draw_axes__.m: Fix concatenation of handles.
 
--- a/scripts/plot/__go_draw_axes__.m	Wed Oct 15 11:52:39 2008 -0400
+++ b/scripts/plot/__go_draw_axes__.m	Wed Oct 15 14:19:33 2008 -0400
@@ -1360,51 +1360,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))
@@ -1435,7 +1448,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
@@ -1449,16 +1462,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
--- a/scripts/plot/newplot.m	Wed Oct 15 11:52:39 2008 -0400
+++ b/scripts/plot/newplot.m	Wed Oct 15 14:19:33 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");