Revision: 7096
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7096&view=rev
Author:   ryanmay
Date:     2009-05-07 19:33:33 +0000 (Thu, 07 May 2009)

Log Message:
-----------
Move from LABELPAD class attribute on an Axis to a labelpad instance attribute. 
 Add a label argument to Axes.set_[xy]label to control the spacing between a 
label and its axis.

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/lib/matplotlib/axes.py
    trunk/matplotlib/lib/matplotlib/axis.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2009-05-07 18:14:01 UTC (rev 7095)
+++ trunk/matplotlib/CHANGELOG  2009-05-07 19:33:33 UTC (rev 7096)
@@ -1,4 +1,8 @@
 ======================================================================
+2009-05-07 'labelpad' can now be passed when setting x/y labels. This
+           allows controlling the spacing between the label and its
+           axis. - RMM
+
 2009-05-06 print_ps now uses mixed-mode renderer. Axes.draw rasterize
            artists whose zorder smaller than rasterization_zorder.
            -JJL

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py     2009-05-07 18:14:01 UTC (rev 
7095)
+++ trunk/matplotlib/lib/matplotlib/axes.py     2009-05-07 19:33:33 UTC (rev 
7096)
@@ -1579,7 +1579,7 @@
         """
         Get zorder value below which artists will be rasterized
         """
-        return self._rasterization_zorder 
+        return self._rasterization_zorder
 
 
     def autoscale_view(self, tight=False, scalex=True, scaley=True):
@@ -1678,8 +1678,8 @@
             dsu = [l for l in dsu if l[0] >= rasterization_zorder]
         else:
             dsu_rasterized = []
-            
-            
+
+
         # the patch draws the background rectangle -- the frame below
         # will draw the edges
         if self.axison and self._frameon:
@@ -2721,14 +2721,16 @@
         label = self.xaxis.get_label()
         return label.get_text()
 
-    def set_xlabel(self, xlabel, fontdict=None, **kwargs):
+    def set_xlabel(self, xlabel, fontdict=None, labelpad=None, **kwargs):
         """
         call signature::
 
-          set_xlabel(xlabel, fontdict=None, **kwargs)
+          set_xlabel(xlabel, fontdict=None, labelpad=None, **kwargs)
 
         Set the label for the xaxis.
 
+        *labelpad* is the spacing in points between the label and the x-axis
+
         Valid kwargs are Text properties:
         %(Text)s
         ACCEPTS: str
@@ -2738,6 +2740,7 @@
             :meth:`text`
                 for information on how override and the optional args work
         """
+        if labelpad is not None: self.xaxis.labelpad = labelpad
         return self.xaxis.set_label_text(xlabel, fontdict, **kwargs)
     set_xlabel.__doc__ = cbook.dedent(set_xlabel.__doc__) % martist.kwdocd
 
@@ -2748,14 +2751,16 @@
         label = self.yaxis.get_label()
         return label.get_text()
 
-    def set_ylabel(self, ylabel, fontdict=None, **kwargs):
+    def set_ylabel(self, ylabel, fontdict=None, labelpad=None, **kwargs):
         """
         call signature::
 
-          set_ylabel(ylabel, fontdict=None, **kwargs)
+          set_ylabel(ylabel, fontdict=None, labelpad=None, **kwargs)
 
         Set the label for the yaxis
 
+        *labelpad* is the spacing in points between the label and the y-axis
+
         Valid kwargs are Text properties:
         %(Text)s
         ACCEPTS: str
@@ -2765,6 +2770,7 @@
             :meth:`text`
                 for information on how override and the optional args work
         """
+        if labelpad is not None: self.yaxis.labelpad = labelpad
         return self.yaxis.set_label_text(ylabel, fontdict, **kwargs)
     set_ylabel.__doc__ = cbook.dedent(set_ylabel.__doc__) % martist.kwdocd
 
@@ -3816,7 +3822,7 @@
 
           h, l = ax.get_legend_handles_labels()
           ax.legend(h, l)
-        
+
         """
 
         handles = []

Modified: trunk/matplotlib/lib/matplotlib/axis.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axis.py     2009-05-07 18:14:01 UTC (rev 
7095)
+++ trunk/matplotlib/lib/matplotlib/axis.py     2009-05-07 19:33:33 UTC (rev 
7096)
@@ -500,9 +500,8 @@
 
     * :attr:`transData` - transform data coords to display coords
     * :attr:`transAxis` - transform axis coords to display coords
-
+    * :attr:`labelpad` - number of points between the axis and its label
     """
-    LABELPAD = 5
     OFFSETTEXTPAD = 3
 
     def __str__(self):
@@ -538,6 +537,7 @@
 
         self._autolabelpos = True
         self.label = self._get_label()
+        self.labelpad = 5
         self.offsetText = self._get_offset_text()
         self.majorTicks = []
         self.minorTicks = []
@@ -1267,7 +1267,7 @@
             else:
                 bbox = mtransforms.Bbox.union(bboxes)
                 bottom = bbox.y0
-            self.label.set_position( (x, bottom - 
self.LABELPAD*self.figure.dpi / 72.0))
+            self.label.set_position( (x, bottom - 
self.labelpad*self.figure.dpi / 72.0))
 
         else:
             if not len(bboxes2):
@@ -1275,7 +1275,7 @@
             else:
                 bbox = mtransforms.Bbox.union(bboxes2)
                 top = bbox.y1
-            self.label.set_position( (x, top+self.LABELPAD*self.figure.dpi / 
72.0))
+            self.label.set_position( (x, top+self.labelpad*self.figure.dpi / 
72.0))
 
     def _update_offset_text_position(self, bboxes, bboxes2):
         """
@@ -1506,7 +1506,7 @@
                 bbox = mtransforms.Bbox.union(bboxes)
                 left = bbox.x0
 
-            self.label.set_position( (left-self.LABELPAD*self.figure.dpi/72.0, 
y))
+            self.label.set_position( (left-self.labelpad*self.figure.dpi/72.0, 
y))
 
         else:
             if not len(bboxes2):
@@ -1515,7 +1515,7 @@
                 bbox = mtransforms.Bbox.union(bboxes2)
                 right = bbox.x1
 
-            self.label.set_position( 
(right+self.LABELPAD*self.figure.dpi/72.0, y))
+            self.label.set_position( 
(right+self.labelpad*self.figure.dpi/72.0, y))
 
     def _update_offset_text_position(self, bboxes, bboxes2):
         """


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to