Thanks for figuring this out, Tom. I'd also be interested in a Reactive and Interact solution.
On Thursday, 28 July 2016 23:42:16 UTC+1, Thomas Hudson wrote: > > I managed to work out a solution in the end, using the clear_output > command and forcing IJulia to display the plot. If anyone knows of a > fancier solution with the Reactive and Interact packages, I'd still be > interested. > > *Inline version: *(really slow for me) > using PyPlot > pygui(false) > x = linspace(0,1,100) > PyPlot.hold(false) > for t = -1:.1:1 > IJulia.clear_output(true) > plot(x, t*(1-x).*x) > axis([0,1, -.3, .3]) > display(gcf()) > end > > *Interactive version:* > using PyPlot > pygui(true) > x = linspace(0,1,100) > PyPlot.hold(false) > for t = -1:.1:1 > IJulia.clear_output(true) > p = plot(x, t*(1-x).*x) > axis([0,1, -.3, .3]) > PyPlot.draw() > end > > On Monday, 25 July 2016 15:23:23 UTC+2, Thomas Hudson wrote: >> >> Since Julia 0.4.6, this solution no longer seems to work: the code >> reverts to plotting only the final frame calculated. >> >> Does anyone have any idea how to tweak the code and get identical >> on-the-fly plotting behaviour with PyPlot under Julia 0.4.6? >> >> Thanks for any help you can give, >> >> Tom >> >> On Thursday, 27 November 2014 22:12:14 UTC+1, Christoph Ortner wrote: >>> >>> And here is the working code: >>> >>> [1] >>> using Gadfly,Reactive,Interact,PyPlot >>> myfig = figure() >>> function myplot(data) >>> withfig(myfig) do >>> PyPlot.plot(data[1], data[2]) >>> axis([0,1,-.3,.3]) >>> end >>> end >>> x = linspace(0,1,100) >>> myinput=Input((x,0*x)) >>> lift(myplot, myinput) >>> >>> [2] >>> x = linspace(0,1,100) >>> for t = -1:.1:1 >>> y = t * x .*(1-x) >>> push!(myinput,(x, y)) >>> end >>> >>> >>> On Thursday, 27 November 2014 21:11:22 UTC, Christoph Ortner wrote: >>>> >>>> Hi Steven, >>>> >>>> That worked! Thank you. >>>> >>>> (Though admittedly I did not fully understand your explanation.) >>>> >>>> All the best, >>>> Christoph >>>> >>>> On Thursday, 27 November 2014 19:04:12 UTC, Steven G. Johnson wrote: >>>>> >>>>> PyPlot, like the Python package of the same name, plots as a side >>>>> effect. You can use the withfig function to wrap PyPlot commands and make >>>>> them functional (returning the figure object as the withfig return value >>>>> rather than displaying it as a side effect). This allows Pyplot to be >>>>> used >>>>> with @manipulate, but should also work with other Reactive functions. >>>> >>>>
