offset_copy in transforms.py... Gone?

Hi All,

    I have upgraded matplotlib from an old version I was using
(0.91.2) to the very latest one (0.98.1). In one of my applications, I
am using this code:

from matplotlib.transforms import offset_copy

def offset(ax, x, y):
    return offset_copy(ax.transData, x=x, y=y, units='dots')

Right now I get:

Traceback (most recent call last):
  File "E:\MyProjects\SimKill\SimKill.py", line 9, in <module>
    from PlotPage import PlotPage
  File "E:\MyProjects\SimKill\PlotPage.py", line 11, in <module>
    from matplotlib.transforms import offset_copy
ImportError: cannot import name offset_copy

Is offset_copy gone? How can I modify my code to get back the original
behaviour?

Thank you for your suggestions.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

Yes, this is one of the casualties of the transforms refactoring in 0.98. The new transformation framework is documented here:

http://matplotlib.sourceforge.net/doc/html/devel/transformations.html

Most of the changes from 0.91 to 0.98 are documented here:

http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/API_CHANGES?view=markup

...but it seems offset_copy was overlooked (probably because no code internal to matplotlib was using it.)

You can do something like this to simulate offset_copy:

  return ax.transData + transforms.Affine2D().translate(x, y)

Let me know if that works in your context. If not, I'm glad to help.

Cheers,
Mike

Andrea Gavana wrote:

···

Hi All,

    I have upgraded matplotlib from an old version I was using
(0.91.2) to the very latest one (0.98.1). In one of my applications, I
am using this code:

from matplotlib.transforms import offset_copy

def offset(ax, x, y):
    return offset_copy(ax.transData, x=x, y=y, units='dots')

Right now I get:

Traceback (most recent call last):
  File "E:\MyProjects\SimKill\SimKill.py", line 9, in <module>
    from PlotPage import PlotPage
  File "E:\MyProjects\SimKill\PlotPage.py", line 11, in <module>
    from matplotlib.transforms import offset_copy
ImportError: cannot import name offset_copy

Is offset_copy gone? How can I modify my code to get back the original
behaviour?

Thank you for your suggestions.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA