Reply To: TEES P
Made some changes to the code, it runs on Spyder 3.2.6
On Tue, Apr 13, 2021 at 2:42 PM Jim Lareau <[email protected]> wrote:
> It looks like you are calling the FuncAnimation module instead of
> FuncAnimation function within the module.
>
> Try importing the module like this:
>
> import matplotlib.animation as manimation
>
> And changing your function call like this:
>
> anim = manimation.FuncAnimation(fig, animate,
> frames=len(temperature)//skip, interval=20)
>
> Regards,
>
> Jim
>
> On Tue, Apr 13, 2021, 3:38 PM TEES P <[email protected]> wrote:
>
>> dear friends i am facing the error below.
>> could you please help me how to solve it. thanks.
>>
>> *error*
>>
>> anim = FuncAnimation(fig, animate, frames=len(temperature)//skip,
>> interval=20)
>>
>> TypeError: 'module' object is not callable
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/spyderlib/26ae2086-7673-46f1-9086-b182c3fa0fe3n%40googlegroups.com
>> <https://groups.google.com/d/msgid/spyderlib/26ae2086-7673-46f1-9086-b182c3fa0fe3n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/spyderlib/CAC26ZyiPmusUypLX5QsGRomX-eypSFGPtcpMoXv%2BOHxdJTd_kw%40mail.gmail.com
> <https://groups.google.com/d/msgid/spyderlib/CAC26ZyiPmusUypLX5QsGRomX-eypSFGPtcpMoXv%2BOHxdJTd_kw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/spyderlib/CAGGyJTos1Gi4N4mw6xs9ZUXCWTmStbw73T%3DhAjBP_8UYkCvRTw%40mail.gmail.com.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation, rc
import IPython.display as HTML
D = 1e-5
L = 0.1
tmax = 100
x = np.linspace(0, 0.1, 101)
a = L/100
time = np.linspace(0, tmax, 10**4+1)
h = tmax/1e4
T = 50*np.ones(101) # initial conditions
T[0] = 0 # BCs
T[-1] = 100
temperature = []
for t in time:
temperature.append(T.copy())
T[1:-1] += h*D/a**2*(T[2:] + T[:-2] - 2*T[1:-1])
skip = 100
fig = plt.figure()
line, = plt.plot([], "r")
plt.xlim(0, L)
plt.ylim(0, 100)
def animate(frame):
y = temperature[frame*skip]
line.set_data(x, y)
anim = animation.FuncAnimation(fig, animate, frames=len(temperature)//skip, interval=20)
HTML(anim.to_html5_video())
rc('animation', html='html5')