JupyterLab Desktop 中带有 ipywidgets 的 matplotlib 小部件

问题描述 投票:0回答:1

我在 JupyterLab Desktop 中使用

%matplotlib widget
时遇到问题

首先:当我运行

df.plot()
一次时,效果很好,我可以看到图形和光标,但是当我再次运行它时,我只得到
<Axes: >

其次:当我运行

widgets.interact()
时,结果显示在我的日志文件中(因此没有光标)。

我试过了

out = widgets.Output(layout={'border': '1px solid black'})

with out: display(widgets.VBox([widgets.GridBox(test.children[:nnn-4], layout=widgets.Layout(grid_template_columns="repeat(5, auto)")), test.children[nnn-4], test.children[nnn-3], test.children[nnn-2], test.children[nnn-1]] ))

Vbox 显示正确,但图表仍在我的日志中而不是常规面板中。

有办法解决吗?

python matplotlib jupyter jupyter-lab ipywidgets
1个回答
0
投票

我曾经遇到过类似的问题,图形是在控制台而不是输出面板中绘制的。就我而言,这个问题可以通过

解决
plot = df.plot()
fig = plot.figure
fig.canvas.draw()
fig.canvas.flush_events()

我想你可以从这个文档中得到一些帮助:交互式数字

© www.soinside.com 2019 - 2024. All rights reserved.