| 
     
      
      
      From: <md...@us...> - 2008-07-21 22:42:54
      
     
   | 
Revision: 5804
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5804&view=rev
Author:   mdboom
Date:     2008-07-21 22:42:52 +0000 (Mon, 21 Jul 2008)
Log Message:
-----------
Re-introduce offset_copy
Modified Paths:
--------------
    trunk/matplotlib/API_CHANGES
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/lib/matplotlib/transforms.py
Modified: trunk/matplotlib/API_CHANGES
===================================================================
--- trunk/matplotlib/API_CHANGES	2008-07-21 19:39:12 UTC (rev 5803)
+++ trunk/matplotlib/API_CHANGES	2008-07-21 22:42:52 UTC (rev 5804)
@@ -130,8 +130,6 @@
 
       Transform.inverse_xy_tup(points)		Transform.inverted().transform(points)
 
-      offset_copy(trans, x, y)                  trans + Affine2D().translate(x, y)
-
     axes.py
       Axes.get_position()			Axes.get_position()
         [Axes.get_position() used to return a list of points, not it
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2008-07-21 19:39:12 UTC (rev 5803)
+++ trunk/matplotlib/CHANGELOG	2008-07-21 22:42:52 UTC (rev 5804)
@@ -1,3 +1,6 @@
+2008-07-21 Re-introduced offset_copy that works in the context of the
+           new transforms. - MGD
+
 2008-07-21 Committed patch by Ryan May to add get_offsets and
            set_offsets to Collections base class - EF
 
Modified: trunk/matplotlib/lib/matplotlib/transforms.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/transforms.py	2008-07-21 19:39:12 UTC (rev 5803)
+++ trunk/matplotlib/lib/matplotlib/transforms.py	2008-07-21 22:42:52 UTC (rev 5804)
@@ -2144,6 +2144,27 @@
         ((a < b) and (a < val and b > val))
         or (b < val and a > val))
 
+def offset_copy(trans, fig, x=0.0, y=0.0, units='inches'):
+    '''
+    Return a new transform with an added offset.
+      args:
+        trans is any transform
+      kwargs:
+        fig is the current figure; it can be None if units are 'dots'
+        x, y give the offset
+        units is 'inches', 'points' or 'dots'
+    '''
+    if units == 'dots':
+        return trans + Affine2D().translate(x, y)
+    if fig is None:
+        raise ValueError('For units of inches or points a fig kwarg is needed')
+    if units == 'points':
+        x /= 72.0
+        y /= 72.0
+    elif not units == 'inches':
+        raise ValueError('units must be dots, points, or inches')
+    return trans + ScaledTranslation(x, y, fig.dpi_scale_trans)
+
 if __name__ == '__main__':
     import copy
     from random import random
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |