widget updating plot; plot disappears

48 views
Skip to first unread message

Randy Heiland

unread,
Feb 19, 2018, 11:13:02 AM2/19/18
to Project Jupyter
Hello,

I was testing the following on https://try.jupyter.org/  and wondering why the plot sometimes disappears:

%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt

def f(p):
    plt.figure(2)
    nx = 10
    ny = 10
    x = np.linspace(1, nx, nx)
    y = np.linspace(1, ny, ny)
    xv, yv = np.meshgrid(x, y)

    rgb = np.zeros((nx*ny,3))
    rgb[:,0] += 1
    rgb[:][p-1] = [0,1,0]

    area=200
    plt.scatter(xv, yv, marker='s', s=area, c=rgb)

    plt.xticks([])
    plt.yticks([])
#    plt.show()

from ipywidgets import interact, interactive
interactive_plot = interactive(f, p=(0, 100))
interactive_plot

Randy Heiland

unread,
Feb 19, 2018, 1:09:44 PM2/19/18
to Project Jupyter
I seem to have fixed my initial problem - rf. attached .ipynb.  

Next question - how do I avoid continuous update when a slider is moved? 

thanks, Randy
mockup3.ipynb

Jason Grout

unread,
Feb 21, 2018, 4:23:06 PM2/21/18
to jup...@googlegroups.com
You can use the interact_manual function. See http://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html#Disabling-continuous-updates

Jason


--
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+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/886fd352-09b5-4e50-858a-ebf7c8d3f508%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Randy Heiland

unread,
Feb 21, 2018, 7:49:20 PM2/21/18
to jup...@googlegroups.com
Any idea why the "continuous_update=False" doesn't work (for me)? Does it work for others? - rf. attached .ipynb.

thanks, Randy

To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/886fd352-09b5-4e50-858a-ebf7c8d3f508%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Project Jupyter" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jupyter/732c6aozcIE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

Jason Grout

unread,
Feb 23, 2018, 7:05:17 PM2/23/18
to jup...@googlegroups.com
continuous_update is an option for a slider, not for the interactive command. Try doing:

interact_manual(f, p=(0, 100))

(and I agree that we should refactor these interact and interactive commands to be more consistent and powerful, and happy to help someone do it.)

Jason


To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/886fd352-09b5-4e50-858a-ebf7c8d3f508%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Project Jupyter" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jupyter/732c6aozcIE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jupyter+u...@googlegroups.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+u...@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages