yes, this one works great (I think aside from formatting it may actually be identical to the version I derived from @cstjean’s code above ). Thank you.
EDIT: not it only created a gks.svg
not a gks.mov
.
yes, this one works great (I think aside from formatting it may actually be identical to the version I derived from @cstjean’s code above ). Thank you.
EDIT: not it only created a gks.svg
not a gks.mov
.
Without the clear_output
all the plots I am generating are put into the cell one after another.
If I do default(show=true)
then depending on the backend I get various different behaviours that I don’t like. E.g. with GR I get an external window instead of inline, while with Plotlyjs I get the following:
One more comment: the behaviour also seems to depend heavily on the browser. In Safari Plotlyjs works well in the way described above, while in Chrome it buffers and only shows the final result.
using PlotlyJS you may want to check out the restyle!
function, which allows you to efficiently edit an existing plot. It looks like setxy!
in Plots.jl should use that.
thank you - this also looks really useful.
I just added support for this in Plots (because I needed it ;))
See: Plots Inline display in Jupyter - YouTube and https://github.com/tbreloff/Plots.jl/pull/597
Is there a way to set the animation speed (e.g. redraw per seconds)?
I am thinking of “replaying” data at the same speed they where acquired (or slower/faster) without first generating a video file.
You just need to sleep in the loop. It would be nice to have a macro that does this.
I see that the speed is limited by the re-plot (I am using Plots with the GR backend) and it is not constant (it slows down and speeds up; due to a cpu load?)
Do you see the same performance when you use GR’s external window instead of plotting within the notebook? I’ve found GR to be impressively fast and able to handle pretty high frame-rates for my real-time audio plotting stuff (plotting every 10ms or so), but I’ve never tried it inside the notebook.
I did not say that (sorry): I’m plotting in an external window (Julia REPL on Linux, on an i7 machine), not inside the notebook.
It seems that GR.plot is faster (4 or 5 times faster) than GR through Plots.plot, and does not show any speed change during the animation.
Using Plots with the gr() backend does not require any sleep cycles, e.g.
using Plots; gr(); default(show=:inline);
for i=1:10
histogram(randn(10000))
end
Is this a general impression, or did you observe this behavior with a specific plot type? The import
and setup might be slower (with Plots), but drawing speed should not differ significantly.
If so, could you provide an example ?
I have a signal acquired at 200 Hz for almost 24 minutes, that is more than 284_000 points.
I import data through DataFrames.readtable(), getting a 2 columns (seconds and mV) dataframe .
I do not know if I use the more efficient way for the animations. Here is what I do.
StatPlots
(I use StatPlots but I checked the speed with Plots and is the same):
widthS = 120; # width of the recording to plot in the window (in seconds)
nPoints = widthS * 200 # number of points to plot
for n = 1:1:(length(data[:,2])-nPoints);
StatPlots.plot(data[n:n+nPoints,:], :s, :mV) |> display
end
It took ~134 seconds for the animation to complete the first 30 seconds of the recording. If I add options to the plot (e.g. ylims, axis ticks, etc.) the speed further decreases.
GR
widthS = 120; # width of the recording to plot in the window (in seconds)
nPoints = widthS * 200 # number of points to plot
for n = 1:1:(length(data[:,2])-nPoints);
GR.plot(data[n:n+nPoints,1], data[n:n+Points,2])
end
The GR.plot took ~38 seconds for the animation to complete the first 30 seconds (~3.5 times faster than Plots.plot.
You’re creating a brand new plot every time, which has overhead compared to
a direct GR call. You should create the plot once and then update the
series in the loop.
Ok, thanks. Any example?
julia> p = plot(1)
julia> for i=1:20
p[1] = (1:10,rand(10))
end; p
Hi @tbreloff,
I probably miss something. I tried out your example but got no animation, just the plot of the final iteration (through the the “p” outside the loop): no updating occurs inside the loop.
I tried to figure out how to get it working (e.g. with the “p” inside the loop) but with no success.
What’s wrong? May you please point me to some documentation? How are plots updated?
Thanks
This was not a complete animation example, just a demo of updating the
underlying data. I’m sure you can figure it out yourself if you think on it
more.
None of the examples above worked for me in IJulia, except those with PyPlot.
I got the GR and Plots examples to work in IJulia only by adding a sleep(0.01) command.