【发布时间】:2019-05-22 07:46:46
【问题描述】:
我的目标是让 Jupyter 笔记本中的一个单元格显示多个交互式小部件。具体来说,我想有四个滑块来裁剪图像,然后另一个单独的滑块来旋转这个裁剪的图像。当然,当我运行代码时,应该显示这两个图。这是我所拥有的。
def image_crop(a,b,c,d):
img_slic=frame[a:b,c:d]
plt.figure(figsize=(8,8))
plt.imshow(img_slic,cmap='RdBu')
return a,b,c,d
interactive_plot = interactive(image_crop, a = widgets.IntSlider(min=0,max=2000,step=10,value=500,description='Vertical_Uppper'),
b = widgets.IntSlider(min=0,max=2000,step=10,value=500,description='Vertical_Lower'),
c = widgets.IntSlider(min=0,max=1000,step=10,value=500,description='Horizontal_Left'),
d = widgets.IntSlider(min=0,max=1000,step=10,value=500,description='Horizontal_Right') )
interactive_plot
def image_rot(i):
img_rot=scipy.ndimage.rotate(frame_slic.T,i)
plt.figure(figsize=(8,8))
plt.imshow(img_rot,cmap='RdBu')
return i
interactive_plot_2 = interactive(image_rot, i =
widgets.IntSlider(min=-180,max=180,step=1,value=0,description='Rotation'))
我可以将它放在两个单元格中(第一个单元格,而第二个单元格旋转),但不能在一个单元格中。
【问题讨论】:
标签: python widget jupyter-notebook interactive