I have a strange error which I can't fix without your help. After I set an image with imshow in matplotlib it stays the same all the time even if I change it with the method set_data. Just take a look on this example:

import numpy as np
from matplotlib import pyplot as plt


def newevent(event):
    haha[1,1] += 1
    img.set_data(haha)
    print img.get_array()    # the data is change at this point
    plt.draw()

haha = np.zeros((2,2))
img = plt.imshow(haha)
print img.get_array()        # [[0,0],[0,0]]
plt.connect('button_press_event', newevent)
plt.show()

After I plot it, the method set_data doesn't change anything inside the plot. Can someone explain me why?

EDIT

Just added a few lines to point out what I actually want to do. I want to redraw the data after I press a mouse button. I don't want to delete the whole figure, because it would be stupid if only one thing changes.

Edit
Report