I am just trying to reproduce this simple example of an animation in Matplotlib but using PyPlot in Julia. I am having difficulties with the definition of the iterator simData() that is passed to the function funcAnimation , because it seems that PyPlot doesn't recognize the iterator that I defined in Julia (via a Task) as such.
Here is my approach to define the same function simData():
function simData()
t_max = 10.0
dt = 0.05
x = 0.0
t = 0.0
function it()
while t < t_max
x = sin(pi*t)
t = t+dt
produce(x,t)
end
end
Task(it)
end
As you can check, this kind of iterator yields in theory the same values than the python simData() generator of the example (try for example collect(simData()). However, I got this error when I try to do the animation
LoadError: PyError (:PyObject_Call) <type 'exceptions.TypeError'>
TypeError('PyCall.jlwrap object is not an iterator',)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/animation.py", line 1067, in __init__
TimedAnimation.__init__(self, fig, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/animation.py", line 913, in __init__
*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/animation.py", line 591, in __init__
self._init_draw()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/animation.py", line 1092, in _init_draw
self._draw_frame(next(self.new_frame_seq()))
while loading In[5], in expression starting on line 42
in pyerr_check at /home/diegotap/.julia/v0.4/PyCall/src/exception.jl:56
[inlined code] from /home/diegotap/.julia/v0.4/PyCall/src/exception.jl:81
in pycall at /home/diegotap/.julia/v0.4/PyCall/src/PyCall.jl:402
in call at /home/diegotap/.julia/v0.4/PyCall/src/PyCall.jl:429
As I mentioned, I think the problem is that the Julia iterator is not recognized as such by Python. Do you have any idea about how to fix that?
PS: Here is a Jupyter notebook with the full code that I used to do the animation.