FuncAnimation set ylim

hello my script is this:



import matplotlib.pyplot as plt
import matplotlib.animation as animation
import matplotlib.ticker as ticker
plt.style.use(‘dark_background’)

fig = plt.figure()

#plt.subplots_adjust(bottom=0.30)

ax = fig.add_subplot(1, 1 , 1)
lista_y_vals = 

lista_x_vals = 


def animate (i, lista_y_vals, lista_x_vals):
     mio_f = open(‘animation_y.ani’, ‘r’)
     valore_y = mio_f.readline()
     mio_f.close()
     lista_y_vals.append(valore_y)
     lista_x_vals.append(i)
     ax.clear()
    #fig.axes[0].set_ylim(0, 15000)
    #plt.ylim(0, 15000)
     ax.plot(lista_x_vals, lista_y_vals)
     plt.xticks(rotation=45, ha=‘right’)
     plt.title(‘Andamento Y’)
     plt.ylabel(‘Posizione Y’)
     plt.xlabel(‘Tempo’)
     plt.subplots_adjust(bottom=0.30)
     ax.yaxis.set_major_locator(ticker.MaxNLocator(20))
     ax.xaxis.set_major_locator(ticker.MaxNLocator(10))

ani = animation.FuncAnimation(plt.gcf(), animate, fargs=(lista_y_vals, lista_x_vals), interval=1000, cache_frame_data=False)
plt.show()

I’m not able to set the y lim. How can I do this?