I've got two plots which I'd like to make interactive with ipython notebook widgets. The code below is a simplified sample of what I'm trying to do.
import matplotlib.pyplot as plt
import IPython.html.widgets as wdg
def displayPlot1(rngMax = 10):
plt.figure(0)
plt.plot([x for x in range(0, rngMax)])
wdg1 = wdg.interactive(displayPlot1, rngMax = wdg.IntSlider(20))
def displayPlot2(rngMax = 10):
plt.figure(1)
plt.plot([x**2 for x in range(0, rngMax)])
wdg2 = wdg.interactive(displayPlot2, rngMax = wdg.IntSlider(10))
wdg.ContainerWidget([wdg.HTML("""<h1>First Plot</h1>"""),
wdg1,
wdg.HTML("""<h1>Second Plot</h1>"""),
wdg2])
The first problem is that it displays all the widgets first, and two plots one after another at the end:
title1
widget1
title2
widget2
plot1
plot2
I'd like to have:
title1
widget1
plot1
title2
widget2
plot2
Also it seems the whole output gets overwritten as soon as I touch any of the sliders, and displays one plot only (the one I'm changing).
How do I fix this problem? (I potentially can do it if I separate them into two different cells, however I'm planning to do something more complex and it needs to be in one cell eventually)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire