No animation in plots plane?

28 views
Skip to first unread message

DrBwts

unread,
Dec 20, 2019, 12:14:33 PM12/20/19
to spyder
Hi,

Just upadated to 4.0 & trying to run the following code..

import numpy as np
import math as mt
import random
from matplotlib import pyplot as plt
from matplotlib import animation

x
= y = 0
labx
= [0]
laby
= [0]

n
= 100 #int(input("number of moves "))

for i in range(0,n):
    x
= x + np.cos(float(random.randint(0,360)) * (180 / (mt.pi)))
    y
= y + np.sin(float(random.randint(0,360)) * (180 / (mt.pi)))
    labx
.append(x)
    laby
.append(y)

fig
= plt.figure()
line
, = plt.plot(labx, laby, "o-", lw = 2)

def init():
    line
.set_data([], [])
   
return line,


def animate(n):
    line
.set_data(labx[:n+1], laby[:n+1])
   
return line,

anim
= animation.FuncAnimation(fig, animate, init_func = init, frames=200, interval=20, blit=True)

plt
.show()

But I just get an empty plot with no animation.

The animation can be seen by using...

%matplotlib auto
%matpltlib qt

Is there no way of seeing it the plot plane?


Carlos Córdoba

unread,
Dec 20, 2019, 1:44:28 PM12/20/19
to spyd...@googlegroups.com
Hi,

No, there's no way to see animations in the Plots pane because it's only able to show static images (png or svg ones).


Cheers,
Carlos

El 20/12/19 a las 12:14 p. m., DrBwts escribió:
--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/spyderlib/47ecf7be-7bb5-4c64-b090-2d2bf51ce704%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages