changeset 8740:cb0ea772a4af

Initialize axes ticklength property.
author Ben Abbott <bpabbott@mac.com>
date Fri, 13 Feb 2009 18:29:18 -0500
parents d477e57e811c
children 008f3985c8c0
files scripts/ChangeLog scripts/plot/__go_draw_axes__.m src/ChangeLog src/graphics.cc src/graphics.h.in
diffstat 5 files changed, 55 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Fri Feb 13 16:38:27 2009 -0500
+++ b/scripts/ChangeLog	Fri Feb 13 18:29:18 2009 -0500
@@ -1,3 +1,7 @@
+2009-02-13 Ben Abbott <bpabott@mac.com>
+
+	* plot/__go_draw_axes__.m: Respect axes ticklength property.
+
 2009-02-12  John W. Eaton  <jwe@octave.org>
 
 	* general/sortrows.m: Call __sort_rows_idx__, not __sortrows_idx__.
--- a/scripts/plot/__go_draw_axes__.m	Fri Feb 13 16:38:27 2009 -0500
+++ b/scripts/plot/__go_draw_axes__.m	Fri Feb 13 18:29:18 2009 -0500
@@ -1401,57 +1401,67 @@
 
   [fontname, fontsize] = get_fontname_and_size (obj);
 
+  ## A Gnuplot tic scale of 69 is equivalent to Octave's 0.5.
+  ticklength = sprintf ("scale %4.1f", (69/0.5)*obj.ticklength(1));
+
   if (strcmpi (obj.xaxislocation, "top"))
     do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
 	       obj.xticklabel, obj.xcolor, "x2", plot_stream, true, mono,
-	       "border", obj.tickdir, fontname, fontsize, obj.interpreter);
+	       "border", obj.tickdir, ticklength, fontname, fontsize,
+	       obj.interpreter);
     do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
 	       obj.xcolor, "x", plot_stream, true, mono, "border",
-	       "", fontname, fontsize, obj.interpreter);
+	       "", "", fontname, fontsize, obj.interpreter);
   elseif (strcmpi (obj.xaxislocation, "zero"))
     do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
 	       obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono,
-	       "axis", obj.tickdir, fontname, fontsize, obj.interpreter);
+	       "axis", obj.tickdir, ticklength, fontname, fontsize,
+	       obj.interpreter);
     do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
 	       obj.xcolor, "x2", plot_stream, true, mono, "axis",
-	       "", fontname, fontsize, obj.interpreter);
+	       "", "", fontname, fontsize, obj.interpreter);
   else
     do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
 	       obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono,
-	       "border", obj.tickdir, fontname, fontsize, obj.interpreter);
+	       "border", obj.tickdir, ticklength, fontname, fontsize,
+	       obj.interpreter);
     do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
 	       obj.xcolor, "x2", plot_stream, true, mono, "border",
-	       "", fontname, fontsize, obj.interpreter);
+	       "", "", fontname, fontsize, obj.interpreter);
   endif
   if (strcmpi (obj.yaxislocation, "right"))
     do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
 	       obj.yticklabel, obj.ycolor, "y2", plot_stream, ymirror, mono,
-	       "border", obj.tickdir, fontname, fontsize, obj.interpreter);
+	       "border", obj.tickdir, ticklength, fontname, fontsize,
+	       obj.interpreter);
     do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
 	       obj.ycolor, "y", plot_stream, ymirror, mono, "border",
-	       "", fontname, fontsize, obj.interpreter);
+	       "", "", fontname, fontsize, obj.interpreter);
   elseif (strcmpi (obj.xaxislocation, "zero"))
     do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
 	       obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono,
-	       "axis", obj.tickdir, fontname, fontsize, obj.interpreter);
+	       "axis", obj.tickdir, ticklength, fontname, fontsize,
+	       obj.interpreter);
     do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
 	       obj.ycolor, "y2", plot_stream, ymirror, mono, "axis",
-	       "", fontname, fontsize, obj.interpreter);
+	       "", "", fontname, fontsize, obj.interpreter);
   else
     do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
 	       obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono,
-	       "border", obj.tickdir, fontname, fontsize, obj.interpreter);
+	       "border", obj.tickdir, ticklength, fontname, fontsize,
+	       obj.interpreter);
     do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
 	       obj.ycolor, "y2", plot_stream, ymirror, mono, "border",
-	       "", fontname, fontsize, obj.interpreter);
+	       "", "", fontname, fontsize, obj.interpreter);
   endif
   do_tics_1 (obj.ztickmode, obj.ztick, obj.zminortick, obj.zticklabelmode,
 	     obj.zticklabel, obj.zcolor, "z", plot_stream, true, mono,
-	     "border", obj.tickdir, fontname, fontsize, obj.interpreter);
+	     "border", obj.tickdir, ticklength, fontname, fontsize,
+	     obj.interpreter);
 endfunction
 
 function do_tics_1 (ticmode, tics, mtics, labelmode, labels, color, ax,
-		    plot_stream, mirror, mono, axispos, tickdir,
+		    plot_stream, mirror, mono, axispos, tickdir, ticklength,
 		    fontname, fontsize, interpreter)
   persistent warned_latex = false;
   if (strcmpi (interpreter, "tex"))
@@ -1489,11 +1499,11 @@
 	nlabels = numel (labels);
 	fprintf (plot_stream, "set format %s \"%%s\";\n", ax);
 	if (mirror)
-	  fprintf (plot_stream, "set %stics %s %s mirror (", ax, 
-		   tickdir, axispos);
+	  fprintf (plot_stream, "set %stics %s %s %s mirror (", ax, 
+		   tickdir, ticklength, axispos);
 	else
-	  fprintf (plot_stream, "set %stics %s %s nomirror (", ax,
-		   tickdir, axispos);
+	  fprintf (plot_stream, "set %stics %s %s %s nomirror (", ax,
+		   tickdir, ticklength, axispos);
 	endif
  
 	labels = regexprep(labels, "%", "%%");
@@ -1518,11 +1528,11 @@
     else
       fprintf (plot_stream, "set format %s \"%%g\";\n", ax);
       if (mirror)
-	fprintf (plot_stream, "set %stics %s %s mirror (", ax, tickdir,
-		 axispos);
+	fprintf (plot_stream, "set %stics %s %s %s mirror (", ax, tickdir,
+		 ticklength, axispos);
       else
-	fprintf (plot_stream, "set %stics %s %s nomirror (", ax, tickdir,
-		 axispos);
+	fprintf (plot_stream, "set %stics %s %s %s nomirror (", ax, tickdir,
+		 ticklength, axispos);
       endif
       fprintf (plot_stream, " %.15g,", tics(1:end-1));
       fprintf (plot_stream, " %.15g) %s;\n", tics(end), fontspec);
@@ -1535,11 +1545,11 @@
   else
     fprintf (plot_stream, "set format %s \"%%g\";\n", ax);
     if (mirror)
-      fprintf (plot_stream, "set %stics %s %s mirror %s %s;\n", ax, 
-	       axispos, tickdir, colorspec, fontspec);
+      fprintf (plot_stream, "set %stics %s %s %s mirror %s %s;\n", ax, 
+	       axispos, tickdir, ticklength, colorspec, fontspec);
     else
-      fprintf (plot_stream, "set %stics %s %s nomirror %s %s;\n", ax, 
-	       tickdir, axispos, colorspec, fontspec);
+      fprintf (plot_stream, "set %stics %s %s %s nomirror %s %s;\n", ax, 
+	       tickdir, ticklength, axispos, colorspec, fontspec);
     endif
     if (strcmp (mtics, "on"))
       fprintf (plot_stream, "set m%stics 5;\n", ax);
--- a/src/ChangeLog	Fri Feb 13 16:38:27 2009 -0500
+++ b/src/ChangeLog	Fri Feb 13 18:29:18 2009 -0500
@@ -1,3 +1,8 @@
+2009-02-13 Ben Abbott <bpabott@mac.com>
+
+	* graphics.h.in (class axes::properties): Initialize ticklength.
+	* graphics.cc (default_axes_ticklength): New function.
+
 2009-02-13  John W. Eaton  <jwe@octave.org>
 
 	* oct-stream.cc (octave_base_stream::do_gets): Handle CRLF and CR.
--- a/src/graphics.cc	Fri Feb 13 16:38:27 2009 -0500
+++ b/src/graphics.cc	Fri Feb 13 18:29:18 2009 -0500
@@ -201,6 +201,14 @@
 }
 
 static Matrix
+default_axes_ticklength (void)
+{
+  Matrix m (1, 2, 0.01);
+  m(1) = 0.025;
+  return m;
+}
+
+static Matrix
 default_figure_position (void)
 {
   Matrix m (1, 4, 0.0);
@@ -2511,7 +2519,7 @@
   projection = "orthographic";
   tickdir = "in";
   tickdirmode = "auto";
-  ticklength = Matrix (1, 2, 0.1);
+  ticklength = default_axes_ticklength ();
   tightinset = Matrix (1, 4, 0.0);
 
   sx = "linear";
--- a/src/graphics.h.in	Fri Feb 13 16:38:27 2009 -0500
+++ b/src/graphics.h.in	Fri Feb 13 18:29:18 2009 -0500
@@ -2700,7 +2700,7 @@
       radio_property projection , "{orthographic}|perpective"
       radio_property tickdir m , "{in}|out"
       radio_property tickdirmode , "{auto}|manual"
-      array_property ticklength , Matrix (1, 2, 0.1)
+      array_property ticklength , default_axes_ticklength ()
       array_property tightinset r , Matrix (1, 4, 0.0)
       // FIXME -- uicontextmenu should be moved here.
       radio_property units , "{normalized}|inches|centimeters|points|pixels|characters"