I want to run a very simple animation using PyPlot: I use a for loop to
cycle through many different pieces of data, and in each iteration I clear
a plot, plot a new figure, and pause for, say, 0.01 seconds. For instance,
here's a very simple example, where I attempt to animate a sine wave with
increasing amplitude:
using PyPlot
#Generate Data
T = zeros(100,100)
x = linspace(0,2*pi,100)
for i = 1:100
T[:,i] = i/100*sin(x)
end
#Plot Data
for i = 1:100
cla()
axis([0,2pi,-1,1])
plot(x,T[:,i])
pause(0.01)
end
This works reasonably well if I copy and paste it straight into the REPL
(though there is some lag) , but if I run it using IJulia I get some
problems. If I have set
pygui(false)
then no animation is shown, and I only see the final figure after a few
seconds (presumably after the loop has finished), and if I have set:
pygui(true)
then it plots the first image, but then gives the following error:
PyError (:PyObject_Call) <type 'exceptions.RuntimeError'>
RuntimeError('Julia exception: ErrorException("function display_figs does not
accept keyword arguments")',)
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 188, in pause
show(block=False)
while loading In[45], in expression starting on line 9
in pyerr_check at /home/thomas/.julia/v0.3/PyCall/src/exception.jl:58
in pycall at /home/thomas/.julia/v0.3/PyCall/src/PyCall.jl:91
in pause at /home/thomas/.julia/v0.3/PyPlot/src/PyPlot.jl:370
in anonymous at no file:13
Does anyone have any idea what's happening, and in particular why there'd be a
difference between the REPL and IJulia?
Thanks