I am trying to write a script that plots a figure and asks the user to select two points. It then draws a rectangle of which the points are the bottom left and top right corner. The process is then repeated adding a new rectangle each iteration. However, I want it to draw the rectangle immediately after the current points are selected but it does not occur till the next set of points are selected. Anyone know how to fix this?
import matplotlib.pylab as plt
x = rand(10,10)
plt.imshow(x)
select = 'y'
while select == 'y':
select = (raw_input('select points (y or n) ? '))
a, b = plt.ginput(2)
plt.vlines(a[0], a[1], b[1], lw=5)
plt.vlines(b[0], a[1], b[1], lw=5)
plt.hlines(a[1], a[0], b[0], lw=5)
plt.hlines(b[1], a[0], b[0], lw=5)
plt.draw()