diff src/graphics.cc @ 13910:2af665333b86

title positioning taking xaxislocation into account (bug #33418) * graphics.cc (axes::properties::update_title_position): add x label tick height to title position for xaxislocation set to "top"
author Konstantinos Poulios <logari81@googlemail.com>
date Tue, 22 Nov 2011 18:20:41 +0100
parents 32a77debff75
children 3b654a0753b1
line wrap: on
line diff
--- a/src/graphics.cc	Tue Nov 22 17:53:18 2011 +0100
+++ b/src/graphics.cc	Tue Nov 22 18:20:41 2011 +0100
@@ -5113,8 +5113,22 @@
 
       // FIXME: bbox should be stored in axes::properties
       Matrix bbox = get_extent (false);
-      ColumnVector p = xform.untransform (bbox(0)+bbox(2)/2, (bbox(1)-10),
-                                          (x_zlim(0)+x_zlim(1))/2, true);
+
+      ColumnVector p =
+        graphics_xform::xform_vector (bbox(0)+bbox(2)/2,
+                                      bbox(1)-10,
+                                      (x_zlim(0)+x_zlim(1))/2);
+
+      if (x2Dtop)
+        {
+          Matrix ext (1, 2, 0.0);
+          ext = get_ticklabel_extents (get_xtick ().matrix_value (),
+                                       get_xticklabel ().all_strings (),
+                                       get_xlim ().matrix_value ());
+          p(1) -= ext(1);
+        }
+
+      p = xform.untransform (p(0), p(1), p(2), true);
 
       title_props.set_position (p.extract_n(0, 3).transpose ());
       title_props.set_positionmode ("auto");