import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation
#make the figure
# - set up figure, set up axis(xlim,ylim), set up line as tuple for
animation
fig = plt.figure()
ax = plt.axes(xlim=(-10,50), ylim=(1,50))
line, = ax.plot([],[], lw=2)
#initialization function - display bkgd for each frame
#line has function set data, return it as a tuple
def init():
line.set_data([],[])
return line,
speed = 0.01
#animation function - this is where the physics goes
def animate(i): #i is animation frames
x = np.linspace(0,2,100) #creates set of num evenly spaces from 0,2
y = (x - speed * i)+(((x - speed * i)^2)/2)+(((x - speed * i)^3)/6)
line.set_data(x,y)
return line,
anim = animation.FuncAnimation(fig, animate, init_func=init,frames=100,
interval=20, blit=True)
plt.show()
Ich versuche, "e^x" mit der unendlichen Reihen Definition zu approximieren und es in einem Graphen zu plotten.Wie man eine Funktion in Matplotlib animiert
Aus welchem Grund auch immer dieser Code erzeugt ein Dialogfeld mit einem Grundstück für einen Bruchteil einer Sekunde endet dann mit einem Exit-Code von 1.
Ich bin verwirrt, warum das nicht funktioniert.
Wenn ich den ursprünglichen Code ausführe, bekomme ich genau die 'TypeError: ufunc 'bitwise_xor' nicht wiederholt für die Eingabe Typen 'Fehler wiederholt für jeden Schritt. Daher glaube ich nicht, dass die Rückverfolgung irgendwo im Matplotlib-Code unterdrückt wird. Könnte sein, dass es von dem Programm unterdrückt wird, mit dem der Code ausgeführt wird. Schöne Antwort sowieso. – ImportanceOfBeingErnest
Interessant! Ich sehe das Traceback beim Ausführen von der Befehlszeile, aber nicht von PyCharm - muss ein PyCharm-Problem sein. –