I am trying to get interactive plots with Gaston in IJulia notebooks. I am almost there, but there is one final piece of the puzzle that I can’t quite figure out. I have this code in a notebook:
using Gaston, Reactive, Interact
t = 0:0.01:1
@manipulate for phi=0:0.1:6.28
plot(cos.(2π*t+phi))
end
This gets me a slider and an initial plot. When I move the slider, though, what I get is a bunch of slightly different plots in a very long stack; in other words, each new plot is not being displayed on top of the previous one, but below it.
What do I need to do to get this to work? I looked at Gadfly’s code, but I can’t find what they’re doing differently from me.
In Gaston, I add a method to show
:
function Base.show(io::IO, ::MIME"image/svg+xml", x::Figure)
write(io,x.svgdata)
end
and I display the image at the end of every plot
command with:
display(fig)
where Figure
is Gaston’s figure type, fig
is the current figure, and fig.svgdata
contains the actual SVG code that I send to the notebook.
(Let me know if you need to see the whole code: I’m working on a private branch right now, and the code on github produces PNG files instead of SVG code).
Thanks!