by Anonymous » 23 Apr 2025, 10:13
Dieser Code kompiliert nicht, er gibt eine Fehlermeldung.
Code: Select all
fig, ax = plt.subplots()
posX = 0
posY = 0
scat = ax.scatter(pos, 0, c="b", s=5, label=f'der sich bewegende punkt')
ax.set(xlim=[-5, 5], ylim=[-1, 1], xlabel='Ort', ylabel='garnix is 1D')
ax.legend()
def update(frame, posX, posY):
# for each frame, update the data stored on each artist.
x = posX + random.gauss()
y = posY + random.gauss()
posX = posX + random.gauss()
posY = posY + random.gauss()
# update the scatter plot:
scat.set_offsets([x,y])
return (x,y)
ani = animation.FuncAnimation(fig=fig, func=update(posX, posY), frames=240, interval=50)
ani.save('test.mp4')
< /code>
Ich habe erwartet, dass es gut läuft. Genau wie der Code unten < /p>
fig, ax = plt.subplots()
pos = 0
scat = ax.scatter(pos, 0, c="b", s=5, label=f'der sich bewegende punkt')
ax.set(xlim=[-5, 5], ylim=[-1, 1], xlabel='Ort', ylabel='garnix is 1D')
ax.legend()
def update(frame):
# for each frame, update the data stored on each artist.
x = pos + random.gauss()`
# update the scatter plot:
scat.set_offsets([x,0])
return (x)
ani = animation.FuncAnimation(fig=fig, func=update, frames=40, interval=30)
ani.save('test.mp4')
Dieser Code kompiliert nicht, er gibt eine Fehlermeldung.[code]fig, ax = plt.subplots()
posX = 0
posY = 0
scat = ax.scatter(pos, 0, c="b", s=5, label=f'der sich bewegende punkt')
ax.set(xlim=[-5, 5], ylim=[-1, 1], xlabel='Ort', ylabel='garnix is 1D')
ax.legend()
def update(frame, posX, posY):
# for each frame, update the data stored on each artist.
x = posX + random.gauss()
y = posY + random.gauss()
posX = posX + random.gauss()
posY = posY + random.gauss()
# update the scatter plot:
scat.set_offsets([x,y])
return (x,y)
ani = animation.FuncAnimation(fig=fig, func=update(posX, posY), frames=240, interval=50)
ani.save('test.mp4')
< /code>
Ich habe erwartet, dass es gut läuft. Genau wie der Code unten < /p>
fig, ax = plt.subplots()
pos = 0
scat = ax.scatter(pos, 0, c="b", s=5, label=f'der sich bewegende punkt')
ax.set(xlim=[-5, 5], ylim=[-1, 1], xlabel='Ort', ylabel='garnix is 1D')
ax.legend()
def update(frame):
# for each frame, update the data stored on each artist.
x = pos + random.gauss()`
# update the scatter plot:
scat.set_offsets([x,0])
return (x)
ani = animation.FuncAnimation(fig=fig, func=update, frames=40, interval=30)
ani.save('test.mp4')
[/code]