I use the following code snippet on an ipython laptop to save the histogram as a .png file:
plt.savefig(filename, bbox_inches='tight')
It works on my computer, and I tried to run the script on another computer. However, I get the following error when I try to run it on another machine.
AssertionError ---> 119 plt.savefig(filename,bbox_inches='tight') C:\Python27\lib\site-packages\matplotlib\pyplot.pyc in savefig(*args,**kwargs) ---> 472 self.canvas.print_figure(*args,**kwargs) C:\Python27\lib\site-packages\matplotlib\figure.pyc in savefig(self,*args,**kwargs) ---> 1363 self.canvas.print_figure(*args,**kwargs) C:\Python27\lib\site-packages\matplotlib\backend_bases.pyc ---> 2054 bbox_inches = self.figure.get_tightbbox(renderer) C:\Python27\lib\site-packages\matplotlib\figure.pyc in get_tightbbox(self,renderer) ---> 1496 _bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0]) C:\Python27\lib\site-packages\matplotlib\transforms.pyc in union(bboxes) ---> 714 assert(len(bboxes)) AssertionError:
Removing the argument bbox_inches = 'tight' seems to resolve the error and save the file, but there is no image there, but only a completely empty .png file.
I made sure that our versions of python, matplotlib and other packages are all the same. Has anyone come across this before? I think this may be a mistake in matplotlib, but then that would not make sense, since it works fine on my computer, and we have the same versions. Any ideas or suggestions?
source share