Closed
Description
Bug report
Bug summary
Saving a jpg file via plt.savefig("plot.jpg")
fails with a type error in matplotlib 2.2.0rc1. Did the required pillow version change? The docs say it's 2.0 or higher.
Code for reproduction
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
plt.plot([1,3,1])
plt.savefig("plot.jpg")
Actual outcome
Traceback (most recent call last):
File "D:\*******\GI_savefigjpg.py", line 16, in <module>
plt.savefig("plot.jpg")
File "c:\******\python-2.7.10.amd64\lib\site-packages\matplotlib\pyplot.py", line 710, in savefig
res = fig.savefig(*args, **kwargs)
File "c:\******\python-2.7.10.amd64\lib\site-packages\matplotlib\figure.py", line 2033, in savefig
self.canvas.print_figure(fname, **kwargs)
File "c:\******\python-2.7.10.amd64\lib\site-packages\matplotlib\backend_bases.py", line 2261, in print_figure
**kwargs)
File "c:\******\python-2.7.10.amd64\lib\site-packages\matplotlib\backends\backend_agg.py", line 582, in print_jpg
return background.save(filename_or_obj, format='jpeg', **options)
File "c:\******\python-2.7.10.amd64\lib\site-packages\PIL\Image.py", line 1665, in save
save_handler(self, fp, filename)
File "c:\******\python-2.7.10.amd64\lib\site-packages\PIL\JpegImagePlugin.py", line 691, in _save
ImageFile._save(im, fp, [("jpeg", (0, 0)+im.size, 0, rawmode)], bufsize)
File "c:\******\python-2.7.10.amd64\lib\site-packages\PIL\ImageFile.py", line 484, in _save
e = Image._getencoder(im.mode, e, a, im.encoderconfig)
File "c:\******\python-2.7.10.amd64\lib\site-packages\PIL\Image.py", line 430, in _getencoder
return encoder(mode, *args + extra)
TypeError: integer argument expected, got float
Expected outcome
No error should occur.
Matplotlib version
- Operating system: Windows 8.1
- Matplotlib version: 2.2.0rc1
- Matplotlib backend: Agg, also tested with
%matplotlib inline
- Python version: 2.7.10
- Other libraries:
import PIL print PIL.VERSION # prints 1.1.7 print PIL.PILLOW_VERSION # prints 3.0.0