【问题标题】:Update ellipse position interactive matplotlib figure jupyter notebook更新椭圆位置交互式 matplotlib 图 jupyter notebook
【发布时间】:2020-05-19 01:39:03
【问题描述】:

我设法生成了一个交互式 matplotlib 图形,它使用一些 ipywidget 滑块改变了椭圆的位置。
但是绘图显示在新窗口中,我无法在笔记本中找到绘图的有效解决方案。
我可以在 jupyter notebook 中生成其他交互式图形,比如线图,但是用椭圆,没办法..

%matplotlib
from matplotlib import patches
import matplotlib.pyplot as plt
from ipywidgets import interact

fig = plt.figure()
ax = fig.add_subplot(111)

ellipse = patches.Ellipse((0,0), width=50, height=25, angle=15)
ax.add_patch(ellipse)

ax.set_xlim(-100, 100)
ax.set_ylim(-100, 100)

@interact
def update(xcenter=(-50,50), ycenter=(-50,50)):
    ellipse.set_center((xcenter, ycenter))
    #fig.canvas.draw()
    plt.plot()

【问题讨论】:

    标签: python matplotlib jupyter-notebook interactive


    【解决方案1】:

    在大多数情况下使用% matplotlib notebook 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-03
      • 1970-01-01
      • 1970-01-01
      • 2016-11-16
      • 2017-09-03
      • 2018-07-04
      • 1970-01-01
      • 2016-10-27
      相关资源
      最近更新 更多