Whenever I generate an image it very easy to zoom it manually using pylab, i.e. drawing a rectangle around the region we intend to zoom in. I was wondering if it was possible coding this operation.
Here is an example code, where I generate a 100×100 image with random values on each row:
from random import *
from pylab import *
from numpy import *
a=ones((100,100))
image=array([dummy*random() for dummy in a])
imshow(image,extent=[0,1]+[5,6])
In the above example our image extends from 0 to 1 in the x-axis and from 5 to 6 in the y-axis. How can show a zoom on the image, let’s say in the region 0.5
You can use scipy.ndimage.interpolation.zoom() to resize array.
Edit:
Sorry, I misunstand your question. You can use
xlim()andylim()to set the range of X and Y axis: