【问题标题】:Flickering and jumping output in jupyter using interact widget使用交互小部件在jupyter中闪烁和跳跃输出
【发布时间】:2019-04-27 21:25:00
【问题描述】:

我正在尝试在 Jupyter Notebook 中使用 Interact。在那个页面上有点下,它说

有时,您可能会注意到交互输出闪烁和跳跃,导致笔记本滚动位置随着输出的更新而改变。交互式控件有一个布局,因此我们可以将其高度设置为适当的值(当前是手动选择的),这样它就不会在更新时改变大小。

当我尝试复制示例时,我正遇到这个问题。

下面的sn-p...

%matplotlib inline
from ipywidgets import interactive
import matplotlib.pyplot as plt
import numpy as np

def f(m, b):
    plt.figure(2)
    x = np.linspace(-10, 10, num=1000)
    plt.plot(x, m * x + b)
    plt.ylim(-5, 5)
    plt.show()

interactive_plot = interactive(f, m=(-2.0, 2.0), b=(-3, 3, 0.5))
output = interactive_plot.children[-1]
output.layout.height = '350px'
interactive_plot

...应该产生这个输出:

但我只得到这个:

确切地说,滑块确实会弹出半秒钟,但似乎被图表覆盖了。我猜这正是他们正在解决的问题。所以我想我可以使用与output.layout.height = '350px' 中的350 不同的值来解决这个问题,但到目前为止绝对没有成功。我试过 100、200、250、300、750 和 1400。

那么会不会是其他原因导致了这些问题?

感谢您的任何建议!

【问题讨论】:

    标签: python jupyter


    【解决方案1】:

    我刚刚检查了这里提出的解决方案:

    Jupyter Notebook: interactive plot with widgets

    适用于最近的经典 Jupyter。

    为避免闪烁,您可以切换到使用 https://github.com/AaronWatters/jp_doodle -- 看例子 在名为交互式 * 的“功能”下。 jp_doodle dual_canvas 具有抑制中间更新的上下文管理器。

    【讨论】:

      猜你喜欢
      • 2019-03-06
      • 1970-01-01
      • 2019-09-03
      • 2021-12-03
      • 2016-07-23
      • 2017-09-03
      • 2016-07-11
      • 1970-01-01
      • 2013-10-19
      相关资源
      最近更新 更多