python - Matplotlib: no effect of set_data in imshow for the plot -


i have strange error can't fix without help. after set image imshow in matplotlib stays same time if change method set_data. take on example:

import numpy np matplotlib import pyplot plt   def newevent(event):     haha[1,1] += 1     img.set_data(haha)     print img.get_array()    # data change @ 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 plot it, method set_data doesn't change inside plot. can explain me why?

edit

just added few lines point out want do. want redraw data after press mouse button. don't want delete whole figure, because stupid if 1 thing changes.

the problem because have not updated pixel scaling after first call.

when instantiate imshow, sets vmin , vmax initial data, , never touches again. in code, sets both vmin , vmax 0, since data, haha = zeros((2,2)), 0 everywhere.

your new event should include autoscaling img.autoscale() , or explicitly set new scaling terms setting img.norm.vmin/vmax prefer.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -