Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fig=plt.figure(figsize=(float(image.size[0])/my_dpi,float(image.size[1])/my_dpi),dpi=my_dpi)
- ax=fig.add_subplot(111)
- # Remove whitespace from around the image
- fig.subplots_adjust(left=0,right=1,bottom=0,top=1)
- # Set the gridding interval: here we use the major tick interval
- myInterval=100.
- loc = plticker.MultipleLocator(base=myInterval)
- ax.xaxis.set_major_locator(loc)
- ax.yaxis.set_major_locator(loc)
- # Add the grid
- ax.grid(which='major', axis='both', linestyle='-')
- # Add the image
- ax.imshow(image)
- # Find number of gridsquares in x and y direction
- nx=abs(int(float(ax.get_xlim()[1]-ax.get_xlim()[0])/float(myInterval)))
- ny=abs(int(float(ax.get_ylim()[1]-ax.get_ylim()[0])/float(myInterval)))
- # Add some labels to the gridsquares
- for j in range(ny):
- y=myInterval/2+j*myInterval
- for i in range(nx):
- x=myInterval/2.+float(i)*myInterval
- ax.text(x,y,'{:d}'.format(i+j*nx),color='w',ha='center',va='center')
- # Save the figure
- fig.savefig('myImageGrid.tiff',dpi=my_dpi)
- Traceback (most recent call last):
- File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
- func(*targs, **kargs)
- 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
- manager.destroy()
- 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
- self.canvas.destroy()
- AttributeError: FigureManagerGTK3Agg instance has no attribute 'canvas'
- Traceback (most recent call last):
- File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
- func(*targs, **kargs)
- 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
- manager.destroy()
- 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
- self.canvas.destroy()
- AttributeError: FigureManagerGTK3Agg instance has no attribute 'canvas'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement