Repository navigation
PS backend fails to save polar plot #2828
Copy link
Copy link
Closed
Milestone
Description
This code:
from matplotlib.pyplot import figure
fig = figure()
fig.add_subplot(212, polar=True)
fig.savefig('fail.eps')
fails with this error:
Traceback (most recent call last):
File "C:\Users\Ruben\Desktop\test.py", line 13, in <module>
fig.savefig('fail.eps')
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\figure.py", line 1422, in savefig
self.canvas.print_figure(*args, **kwargs)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 167, in print_figure
FigureCanvasAgg.print_figure(self, *args, **kwargs)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\backend_bases.py", line 2220, in print_figure
**kwargs)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\backend_bases.py", line 1947, in print_eps
return ps.print_eps(*args, **kwargs)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\backends\backend_ps.py", line 981, in print_eps
return self._print_ps(outfile, 'eps', *args, **kwargs)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\backends\backend_ps.py", line 1009, in _print_ps
**kwargs)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\backends\backend_ps.py", line 1102, in _print_figure
self.figure.draw(renderer)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\artist.py", line 56, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\figure.py", line 1035, in draw
func(*args)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\artist.py", line 56, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\axes.py", line 2088, in draw
a.draw(renderer)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\artist.py", line 56, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\axis.py", line 1101, in draw
tick.draw(renderer)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\artist.py", line 56, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\axis.py", line 235, in draw
self.gridline.draw(renderer)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\artist.py", line 56, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\lines.py", line 563, in draw
drawFunc(renderer, gc, tpath, affine.frozen())
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\lines.py", line 939, in _draw_lines
self._lineFunc(renderer, gc, path, trans)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\lines.py", line 994, in _draw_dotted
renderer.draw_path(gc, path, trans)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\backends\backend_ps.py", line 575, in draw_path
self._draw_ps(ps, gc, rgbFace)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\backends\backend_ps.py", line 907, in _draw_ps
id = self._get_clip_path(clippath, clippath_trans)
File "C:\WinPython-64bit-3.3.3.2\python-3.3.3.amd64\lib\site-packages\matplotlib\backends\backend_ps.py", line 556, in _get_clip_path
id = self._clip_paths.get((clippath, clippath_transform))
TypeError: unhashable type: 'Affine2D'
This cannot be intentional.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
tacaswell commentedon Feb 21, 2014
What version of mpl are you using?
rubenvb commentedon Feb 21, 2014
I'm using Version 1.3.1 as distributed by WinPython and/or http://www.lfd.uci.edu/~gohlke/pythonlibs/.
fruitfrisje commentedon Mar 19, 2014
Are there already solutions to this problem, I'm having the same problem. It is in the matplotlib that it can't save polar plots....
tacaswell commentedon Mar 19, 2014
@pelson Smells like something is going wrong in the transform stack.
tacaswell commentedon Mar 19, 2014
@fruitfrisje @rubenvb I can not reproduce this on something close to current master. Can either of you test this using the master branch?
fruitfrisje commentedon Mar 19, 2014
Try this:
phi = linspace(0, 2_pi, 200)
figure()
polar(phi, sin(phi)_cos(phi))
grid(True)
savefig("plot_polar.eps", format = 'eps', dpi=1000)
It will give the error.
(using python 3.3.3 with Spyder 2.3.0beta3)
tacaswell commentedon Mar 19, 2014
@fruitfrisje What version of mpl are you using? (
matplotlib.__version__)BUG : add __hash__ to AffineBase
tacaswell commentedon Mar 19, 2014
I can confirm this on master on 3.3, not on 2.7.
This is a side effect of the change in 3 that if a class defines
__eq__then the default__hash__goes away.fruitfrisje commentedon Mar 20, 2014
Sorry for the late reply (out of office), MPL version 1.3.1. We are now gong to test is in python 2.7.3. Will let you know. Is there already a workaround to solve this class problem?
pelson commentedon Mar 20, 2014
I've not tried it, but as a workaround, before you construct the polar plot, try:
This will define a hash function on the affine transform based on the object ID (as it is in Python2) and should fix the problem. @tacaswell also has a fix in the pipeline for v1.4.
HTH
fruitfrisje commentedon Mar 20, 2014
The following error shows up:
TypeError: id() takes exactly one argument (0 given)
pelson commentedon Mar 20, 2014
Clearly there is always something to learn with Python as I don't fully undersand what the problem is, but replacing that line with:
Should be fine. Anyone care to give me a lesson in Python?
fruitfrisje commentedon Mar 20, 2014
@pelson the suggested code above works perfect! Thank you very much so far!!
A totally other question. Is it also possible to save an excel range to an eps? (the range consists of values and text)
BUG : don't use mutable objects as dictionary keys
BUG : don't use mutable objects as dictionary keys
BUG : don't use mutable objects as dictionary keys
BUG : don't use mutable objects as dictionary keys
BUG : don't use mutable objects as dictionary keys