Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. fig=plt.figure(figsize=(float(image.size[0])/my_dpi,float(image.size[1])/my_dpi),dpi=my_dpi)
  2. ax=fig.add_subplot(111)
  3.  
  4. # Remove whitespace from around the image
  5. fig.subplots_adjust(left=0,right=1,bottom=0,top=1)
  6.  
  7. # Set the gridding interval: here we use the major tick interval
  8. myInterval=100.
  9. loc = plticker.MultipleLocator(base=myInterval)
  10. ax.xaxis.set_major_locator(loc)
  11. ax.yaxis.set_major_locator(loc)
  12.  
  13. # Add the grid
  14. ax.grid(which='major', axis='both', linestyle='-')
  15.  
  16. # Add the image
  17. ax.imshow(image)
  18.  
  19. # Find number of gridsquares in x and y direction
  20. nx=abs(int(float(ax.get_xlim()[1]-ax.get_xlim()[0])/float(myInterval)))
  21. ny=abs(int(float(ax.get_ylim()[1]-ax.get_ylim()[0])/float(myInterval)))
  22.  
  23. # Add some labels to the gridsquares
  24. for j in range(ny):
  25. y=myInterval/2+j*myInterval
  26. for i in range(nx):
  27. x=myInterval/2.+float(i)*myInterval
  28. ax.text(x,y,'{:d}'.format(i+j*nx),color='w',ha='center',va='center')
  29.  
  30. # Save the figure
  31. fig.savefig('myImageGrid.tiff',dpi=my_dpi)
  32.  
  33. Traceback (most recent call last):
  34. File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
  35. func(*targs, **kargs)
  36. File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-i686.egg/matplotlib/_pylab_helpers.py", line 86, in destroy_all
  37. manager.destroy()
  38. File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-i686.egg/matplotlib/backends/backend_gtk3.py", line 427, in destroy
  39. self.canvas.destroy()
  40. AttributeError: FigureManagerGTK3Agg instance has no attribute 'canvas'
  41.  
  42. Traceback (most recent call last):
  43. File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
  44. func(*targs, **kargs)
  45. File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-i686.egg/matplotlib/_pylab_helpers.py", line 86, in destroy_all
  46. manager.destroy()
  47. File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-i686.egg/matplotlib/backends/backend_gtk3.py", line 427, in destroy
  48. self.canvas.destroy()
  49. AttributeError: FigureManagerGTK3Agg instance has no attribute 'canvas'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement