Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interact + PyPlot does not work in Jupyter #263

Open
Datseris opened this issue Sep 7, 2018 · 8 comments
Open

Interact + PyPlot does not work in Jupyter #263

Datseris opened this issue Sep 7, 2018 · 8 comments

Comments

@Datseris
Copy link

Datseris commented Sep 7, 2018

MWE:

using PyPlot, Interact
@manipulate for n in slider(100:100:10000; value = 100, label = "n")
   plot(rand(n))
end

This does not update/create a new plot when moving the slider.

@AshtonSBradley
Copy link

one solution:

using PyPlot, Interact
f1=figure(figsize=(6,3))
@manipulate for n in slider(100:100:10000; value = 100, label = "n")
   withfig(f1,clear=true) do
        plot(rand(n))
    end
end

@Datseris
Copy link
Author

Datseris commented Sep 7, 2018

There is another problem, so I keep this open. Let:

using Interact, PyPlot

f1=figure(figsize=(6,3))
line, = plot(1:5, rand(5))
@manipulate for n in slider(100:100:10000; value = 100, label = "n")
   line[:set_data](1:n, rand(n))
end

so even though I change the data of the line, the figure is not updated

@piever
Copy link
Collaborator

piever commented Sep 7, 2018

The

using PyPlot, Interact
f1=figure(figsize=(6,3))
@manipulate for n in slider(100:100:10000; value = 100, label = "n")
   withfig(f1,clear=true) do
        plot(rand(n))
    end
end

works but flickers a lot, so I'm afraid it's not usable in practice. Does anybody know how to get this sort of PyPlot animation to work smoothly in the notebook? Say a for loop that would update a plot in place to create an animation?

@ziotom78
Copy link

…works but flickers a lot.

Does it? In my case it just shows this output:

interact

(Scrolling down to the end of the output reveals no plot.)

@twavv
Copy link
Member

twavv commented Dec 23, 2018

Re: the withfig example

@piever What do you mean when you say it flickers? It's fine for me™ (at least using the webio-retool branch of WebIO) though theres a certain amount of lag if you drag the slider (as we're plotting all the intermediate things and it has to "catch up").

Using [email protected] doesn't display anything for me though.

@piever
Copy link
Collaborator

piever commented Dec 30, 2018

On InteractBase master you can use onchange to avoid the intermediate steps and only update when slider is released, but even with:

using PyPlot, Interact
f1=figure(figsize=(6,3))
wdg = slider(100:100:10000; value = 100, label = "n")
@manipulate for n in Interact.onchange(wdg)
   withfig(f1,clear=true) do
        plot(rand(n))
    end
end

Sometimes before being redisplayed the plot goes white and gives the overall impression is of a flicker (I'm on webio-retool).

@twavv
Copy link
Member

twavv commented Mar 29, 2019

Are you still having these issues? WebIO#master works for me.

Interact PyPlot

@AshtonSBradley
Copy link

AshtonSBradley commented Mar 30, 2019

checking on MacOS with WebIO#master, I still regularly see a flicker on update as reported by @piever , using WebIO#master

testing on WebIO#webio-retool, I get no updates at all, just the initial figure is shown.

just testing in regular notebook, with

Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants