Matplotlib imshow zoom function?

You could use plt. Xlim and plt. Ylim to set the region to be plotted: import matplotlib.

Pyplot as plt import numpy as np data=np. Arange(9). Reshape((3,3)) plt.

Imshow(data) plt. Xlim(0.5, 1.5) plt. Ylim(0.5,1.5) plt.show().

Thanks! I realized I can also crop the array pre-display, but your method preserves the rest of the array. – Andruf Oct 12 at 19:21.

If you do not need the rest of your image, you can define a function that crop the image at the coordinates you want and then display the cropped image. Note: here 'x' and 'y' are the visual x and y (respectively horizontal axe and vertical axe on the image), meaning that it is inverted compared to the real x (row) and y (column) of the numpy array. Import scipy as sp import numpy as np import matplotlib.

Pyplot as plt def crop(image, x1, x2, y1, y2): """ Return the cropped image at the x1, x2, y1, y2 coordinates """ if x2 == -1: x2=image. Shape1-1 if y2 == -1: y2=image. Shape0-1 mask = np.

Zeros(image. Shape) masky1:y2+1, x1:x2+1=1 m = mask>0 return imagem. Reshape((y2+1-y1, x2+1-x1)) image = sp.lena() image_cropped = crop(image, 240, 290, 255, 272) fig = plt.figure() ax1 = fig.

Add_subplot(121) ax2 = fig. Add_subplot(122) ax1. Imshow(image) ax2.

Imshow(image_cropped) plt.show().

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions