Guest User

Untitled

a guest
Nov 20th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. import numpy as np;
  2. import matplotlib as mpl;
  3. mpl.use("Agg");
  4. import matplotlib.pyplot as plt;
  5.  
  6. my_array = np.random.randint(0,100,1000,dtype=int);
  7. fig1 = plt.figure(1, figsize=(20,10));
  8. n, bins, patches = plt.hist(my_array, bins="auto", normed=1, facecolor="blue",alpha=0.8);
  9. plt.ylabel("Freq",fontsize=30);
  10. plt.xlabel("X",fontsize=30);
  11. plt.xticks(fontsize=30);
  12. plt.yticks(fontsize=30);
  13. plt.savefig(fname="./test_pic.jpg",bbox_inches="tight");
  14. plt.close(fig1);
  15.  
  16. Traceback (most recent call last):
  17. File "test.py", line 13, in <module>
  18. plt.savefig(fname="./test_pic.jpg",bbox_inches="tight");
  19. File "/<my_home>/.local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 697, in savefig
  20. res = fig.savefig(*args, **kwargs)
  21. File "/<my_home>/.local/lib/python2.7/site-packages/matplotlib/figure.py", line 1814, in savefig
  22. self.canvas.print_figure(fname, **kwargs)
  23. File "/<my_home>/.local/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2259, in print_figure
  24. **kwargs)
  25. File "/<my_home>/.local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 584, in print_jpg
  26. return background.save(filename_or_obj, format='jpeg', **options)
  27. File "/usr/lib64/python2.7/site-packages/PIL/Image.py", line 1477, in save
  28. save_handler(self, fp, filename)
  29. File "/usr/lib64/python2.7/site-packages/PIL/JpegImagePlugin.py", line 565, in _save
  30. ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)], bufsize)
  31. File "/usr/lib64/python2.7/site-packages/PIL/ImageFile.py", line 470, in _save
  32. e = Image._getencoder(im.mode, e, a, im.encoderconfig)
  33. File "/usr/lib64/python2.7/site-packages/PIL/Image.py", line 395, in _getencoder
  34. return encoder(mode, *args + extra)
  35. TypeError: integer argument expected, got float
Add Comment
Please, Sign In to add comment