I want to use the offline plotting of plotly inside a jupyter notebook and want to manipulate or redraw the plot by using widgets from ipywidgets. Unfortunately I do not manage to update the plots appropiately:

我想使用在jupyter笔记本中缓慢绘制的离线绘图,并希望通过使用来自ipywidgets的小部件来操作或重新绘制绘图。不幸的是,我没有及时更新这些情节:

from ipywidgets import widgets, HBox, Output
import plotly as py
from plotly.offline import iplot
from IPython.display import display

%matplotlib inline
ip_widget = widgets.FloatSlider(
    value=6,
    min=3,
    max=10,
    step=1,
    description='num',
    continuous_update = True
)

ow = Output()
def response(change):
    with ow:
        iplot([{'x':list(range(int(ip_widget.value))), 'y': list(range(int(ip_widget.value)))}])
ip_widget.observe(response)
display(ip_widget)

The provided code has two disadvantages: It plots the graph multiple times. The graph only shows up, if the slider is used. How can I overcome these two issues? Please note that I don't want to use the online plotting capabilities of plotly and I don't want to solve this problem using interact.

所提供的代码有两个缺点:它多次绘制图表。只在使用滑块时才显示图形。如何克服这两个问题?请注意,我不想使用plotly的在线绘图功能,也不想使用interaction解决这个问题。

Thank you very much for your answers.

非常感谢您的回答。

1 个解决方案

#1


1

Have you tried using interact? Here is a very clear example: http://nbviewer.jupyter.org/github/yankev/test/blob/master/plotlywidget_working2.ipynb

你试过使用互动吗?这里有一个非常清楚的例子:http://nbviewer.jupyter.org/github/yankev/test/blob/master/plotlywidget_working2.ipynb

By the way, the interact function lives in ipywidgets (and not IPython.html.widgets anymore). Other than that, the example is pretty much up-to-date.

顺便说一下,交互函数驻留在ipywidgets(而不是IPython.html)中。小部件了)。除此之外,这个例子是最新的。

更多相关文章

  1. python打印列表的下标和值的例子:
  2. python2.7练习小例子(十二)
  3. Tkinter小部件上的垂直和水平滚动条
  4. 创建链表的小例子
  5. 如何在qt上访问父窗口小部件?
  6. LNMP(Linux+Nginx+Mysql+PHP)环境下安装yaf框架并编写一个MVC例子
  7. 简单统计报表例子(存储过程)
  8. unity连接数据库MySQL简单例子
  9. webgote的例子(6)SQL注入(盲注)

随机推荐

  1. 开启 Android 反射调用
  2. Android MediaController
  3. 通过JS或PHP检测Android
  4. Android在设置里面添加新功能的方法
  5. 关于android:focusable属性
  6. [AndroidTips]Android预定义样式
  7. 基于百度地图API的Android公交换乘导航
  8. Android API Level对应Android版本一览表
  9. Unable to resolve target 'android-5'
  10. USB UMS MTP设置过程 (二) UsbDeviceManage