The main thing I have found with using matplotlib with interact is
that you have to do a bit of extra work to make sure that the overall
frame/ticks/limits/etc are the same as you vary your parameter.
Because each call to plt.plot is new, matplotlib has no way of knowing
it should hold those things invariant.

On Sat, Jan 14, 2017 at 9:17 AM,  <mcmcc...@unca.edu> wrote:
> On Saturday, January 14, 2017 at 9:55:31 AM UTC-5, Sylvain Corlay wrote:
>
>> The problem is that the rendering logic for matplotlib resides in the
>> backend. I would recommand using the "notebook" backend for matplotlib which
>> should improve the situation.
>>
>> Or you can use a plotting library for the notebook such as bqplot.
>
>
> Thanks! the notebook backend seemed much worse. bqplot seems very new and,
> I'm guessing that it will be the way to work with 2D graphics in the
> notebook. For the record, I was able to piece together the following after a
> little fiddling:
>
> import numpy as np
> from bqplot import pyplot as plt
> from ipywidgets import interact, FloatSlider
>
> fig = plt.figure(1)
> def myplot(a):
>     xs = np.linspace(-3,3,100)
>     ys = np.sin(a*xs)
>     if fig.marks == []:
>         plt.plot(xs,ys)
>     else:
>         fig.marks[0].y = ys
> demo = interact(myplot, a=FloatSlider(value=1, min=-3, max=3, step=0.01))
> plt.ylim(-1.1,1.1)
> plt.show()
>
> This seems to work quite well.
>
> Thanks again!
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Project Jupyter" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jupyter+unsubscr...@googlegroups.com.
> To post to this group, send email to jupyter@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jupyter/1d4935fd-b035-4c7f-bbf7-8aa04ed20d4b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Brian E. Granger
Associate Professor of Physics and Data Science
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
bgran...@calpoly.edu and elliso...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CAH4pYpQdJ2pNrV6MRBumct7PqJMygJy%2BpcqWBQRhOwBNk%3DSDYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to