ipe-tools icon indicating copy to clipboard operation
ipe-tools copied to clipboard

Compatibility with the new matplotlib 2.0.0?

Open tianyikillua opened this issue 8 years ago • 3 comments

On a minimal example

x = linspace(0, 2*pi, 1000)
y = sin(x)
plot(x, y)
savefig("test.ipe")

I had the following error with the new matplotlib 2.0.0

  File "/usr/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 697, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py", line 1572, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2244, in print_figure
    **kwargs)
  File "/usr/local/hpc/ipe-tools/matplotlib/backend_ipe.py", line 474, in print_ipe
    return self._print_ipe(filename, ipewriter, fh_to_close, **kwargs)
  File "/usr/local/hpc/ipe-tools/matplotlib/backend_ipe.py", line 482, in _print_ipe
    self.figure.draw(renderer)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py", line 1140, in draw
    self.patch.draw(renderer)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/patches.py", line 561, in draw
    renderer.draw_path(gc, tpath, affine, rgbFace)
  File "/usr/local/hpc/ipe-tools/matplotlib/backend_ipe.py", line 293, in draw_path
    dashes = "[" + " ".join(["%g" % x for x in dl]) + "] %g" % offs
TypeError: 'NoneType' object is not iterable

tianyikillua avatar Feb 08 '17 14:02 tianyikillua

I've applied the change from your fork. Anything else I can do?

otfried avatar Oct 23 '18 13:10 otfried

It was only a partial fix since didn't work with contours (pcolormesh for instance). Now there is some more issues with the new version matplotlib 3.0.0, some API have been changed: https://matplotlib.org/api/api_changes.html. I'm getting this message

λ python run_test.py ipe line_styles_reference
# line_styles_reference
Traceback (most recent call last):
  File "tmp.py", line 6, in <module>
    import matplotlib.pyplot as plt
  File "D:\Programs\Miniconda3\lib\site-packages\matplotlib\pyplot.py", line 2371, in <module>
    switch_backend(rcParams["backend"])
  File "D:\Programs\Miniconda3\lib\site-packages\matplotlib\pyplot.py", line 207, in switch_backend
    backend_mod = importlib.import_module(backend_name)
  File "D:\Programs\Miniconda3\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\tianyi\Desktop\ipe-tools\matplotlib\backend_ipe.py", line 31, in <module>
    from matplotlib.cbook import is_string_like, is_writable_file_like, maxdict
ImportError: cannot import name 'is_string_like' from 'matplotlib.cbook'

is_string_like has been indeed removed...

tianyikillua avatar Oct 24 '18 07:10 tianyikillua

Hi, I am having the same kind of problem apparently: I am on Python 3.11 and matplotlib 3.8.3

ImportError: cannot import name 'maxdict' from 'matplotlib.cbook

Anyone managed to solve it?

Thanks

Quantfoam avatar Feb 25 '24 17:02 Quantfoam