in python issues, including some libraries

*) Matplotlib animate the variable scope of the problem

Error message:

UnboundLocalError: local variable 'i' referenced before assignment

  Code:

i=0
def animate(frameno):

    x = mu + sigma * np.random.randn(N)
    n, _ = np.histogram(x, bins, normed=True)
    time_text.set_text(time_template%frameno)
    i+=1
    for rect, h in zip(patches, n):
        rect.set_height(h)
    return patches

  

Guess you like

Origin www.cnblogs.com/Gaoqiking/p/11258442.html