# HG changeset patch
# User Ben Abbott <bpabbott@mac.com>
# Date 1271560780 14400
# Node ID e41444a754700cc926652e6b25281b477bdd3560
# Parent  114376c7cba56e362a3349e93c94a6dd5bd15089
colorbar.m: Consistent treatment of plotboxaspectratio. Add listener for plotboxaspectratiomode.

diff -r 114376c7cba5 -r e41444a75470 scripts/ChangeLog
--- a/scripts/ChangeLog	Sat Apr 17 20:37:51 2010 -0400
+++ b/scripts/ChangeLog	Sat Apr 17 23:19:40 2010 -0400
@@ -1,5 +1,9 @@
 2010-04-17  Ben Abbott <bpabbott@mac.com>
 
+	* plot/colorbar.m: Consistent treatment of plotboxaspectratio. Add
+	listener for plotboxaspectratiomode.
+	* plot/axis.m: Consistent treatment of plotboxaspectratio.
+	* plot/__go_draw_axes__.m: Consistently determine axes position.
 	* plot/private/__actual_axis_position__.m: Fix bug when restoring
 	figure position property to its original value.
 
diff -r 114376c7cba5 -r e41444a75470 scripts/plot/__go_draw_axes__.m
--- a/scripts/plot/__go_draw_axes__.m	Sat Apr 17 20:37:51 2010 -0400
+++ b/scripts/plot/__go_draw_axes__.m	Sat Apr 17 23:19:40 2010 -0400
@@ -46,12 +46,13 @@
     endif
 
     nd = __calc_dimensions__ (axis_obj);
-    pos = axis_obj.position;
-    pos = pos - implicit_margin([1, 2, 1, 2]).*[1, 1, -0.5, -0.5];
+    if (strcmpi (axis_obj.plotboxaspectratiomode, "manual"))
+      pos = __actual_axis_position__ (axis_obj);
+    else
+      pos = axis_obj.position;
+      pos = pos - implicit_margin([1, 2, 1, 2]).*[1, 1, -0.5, -0.5];
+    endif
     if (__gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin"))
-      if (strcmpi (axis_obj.plotboxaspectratiomode, "manual"))
-	pos = __actual_axis_position__ (axis_obj);
-      endif
       if (nd == 2)
 	x = [1, 1];
       else
@@ -72,8 +73,8 @@
       fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2));
       fprintf (plot_stream, "set size %.15g, %.15g;\n", pos(3), pos(4));
 
-      if (strcmpi (axis_obj.plotboxaspectratiomode, "manual"))
-        r = axis_obj.plotboxaspectratio;
+      if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
+        r = axis_obj.dataaspectratio;
         fprintf (plot_stream, "set size ratio %.15g;\n", -r(2)/r(1));
       else
         fputs (plot_stream, "set size noratio;\n");
diff -r 114376c7cba5 -r e41444a75470 scripts/plot/axis.m
--- a/scripts/plot/axis.m	Sat Apr 17 20:37:51 2010 -0400
+++ b/scripts/plot/axis.m	Sat Apr 17 23:19:40 2010 -0400
@@ -164,21 +164,11 @@
       __axis__ (ca, "equal")
       __do_tight_option__ (ca);
     elseif (strcmpi (ax, "square"))
-      if (__gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin"))
-        set (ca, "plotboxaspectratio", [1, 1, 1]);
-      else
-        x = xlim;
-        y = ylim;
-        set (ca, "plotboxaspectratio", [(y(2)-y(1)), (x(2)-x(1)), 1]);
-      endif
+      set (ca, "plotboxaspectratio", [1, 1, 1]);
     elseif  (strcmp (ax, "equal"))
-      if (__gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin"))
-        x = xlim;
-        y = ylim;
-        set (ca, "plotboxaspectratio", [(x(2)-x(1)), (y(2)-y(1)), 1]);
-      else
-        set (ca, "plotboxaspectratio", [1, 1, 1]);
-      endif
+      x = xlim;
+      y = ylim;
+      set (ca, "plotboxaspectratio", [(x(2)-x(1)), (y(2)-y(1)), 1]);
     elseif (strcmpi (ax, "normal"))
       set (ca, "plotboxaspectratiomode", "auto");
 
diff -r 114376c7cba5 -r e41444a75470 scripts/plot/colorbar.m
--- a/scripts/plot/colorbar.m	Sat Apr 17 20:37:51 2010 -0400
+++ b/scripts/plot/colorbar.m	Sat Apr 17 23:19:40 2010 -0400
@@ -158,6 +158,7 @@
 
     addlistener (ax, "clim", {@update_colorbar_clim, hi, vertical})
     addlistener (ax, "plotboxaspectratio", {@update_colorbar_axis, cax})
+    addlistener (ax, "plotboxaspectratiomode", {@update_colorbar_axis, cax})
     addlistener (ax, "position", {@update_colorbar_axis, cax})
 
   endif
@@ -325,31 +326,23 @@
   cpos = [origin, sz];
 
   if (strcmpi (obj.plotboxaspectratiomode, "manual"))
-    if (__gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin"))
-      obj.position = pos;
-      actual_pos = __actual_axis_position__ (obj);
-      if (strfind (cbox, "outside"))
-	scale = 1.0;
-      else
-	scale = 0.9;
-      endif
-      if (sz(1) > sz(2))
-	dx = (1-scale)*actual_pos(3);
-	cpos(1) = actual_pos(1) + dx/2;
-	cpos(3) = actual_pos(3) - dx;
-      else
-	dy = (1-scale)*actual_pos(4);
-	cpos(2) = actual_pos(2) + dy/2;
-	cpos(4) = actual_pos(4) - dy;
-      endif
-      aspect = NaN;
+    obj.position = pos;
+    actual_pos = __actual_axis_position__ (obj);
+    if (strfind (cbox, "outside"))
+      scale = 1.0;
     else
-      if (vertical)
-	aspect = [1, 0.21, 1];
-      else
-	aspect = [0.21, 1, 1];
-      endif
+      scale = 0.9;
     endif
+    if (sz(1) > sz(2))
+      dx = (1-scale)*actual_pos(3);
+      cpos(1) = actual_pos(1) + dx/2;
+      cpos(3) = actual_pos(3) - dx;
+    else
+      dy = (1-scale)*actual_pos(4);
+      cpos(2) = actual_pos(2) + dy/2;
+      cpos(4) = actual_pos(4) - dy;
+    endif
+    aspect = NaN;
   else
     aspect = NaN;
   endif
