views:

129

answers:

1

I am encountering some strange behavior with using the matplotlib.pyplot ginput() function to store clicked points. On the first click, the ranges of the axes of the clicked image change to add 200 on each side. The image remains with this border of whitespace until something new is plotted.

Example code:

import matplotlib.pyplot as plt
plt.imshow(im1)
x = plt.ginput(4)

On the first click of the mouse, the axes change from (0, imageWidth) and (0, imageHeight) to (-200, imageWidth+200) and (-200, imageHeight+200).

The image itself is not affected in any way.
The same behavior occurs when ginput is called on the current figure.

Has anyone else encountered this? Any explanations? Fixes?

+2  A: 

Try

plt.imshow(im1)
plt.axis('image')
x = plt.ginput(4)

I learned this here: http://old.nabble.com/using-ginput-with-images----axes-are-resized--td20270943.html

unutbu