在IPython中使用mpld3.display()无法正常显示图形的问题求助
在IPython中使用mpld3.display()无法正常显示图形的问题求助
各位好,我最近在尝试用mpld3库做一个带交互式图例的绘图示例,代码写完运行后,只返回了一个HTML对象,完全看不到预期的图形,想请教下大家这是怎么回事,该怎么解决?
我的代码如下:
import mpld3 from mpld3 import plugins from mpld3.utils import get_id import numpy as np import collections import matplotlib.pyplot as plt mpld3.enable_notebook() N_paths = 5 N_steps = 100 x = np.linspace(0, 10, 100) y = 0.1 * (np.random.random((N_paths, N_steps)) - 0.5) y = y.cumsum(1) fig, ax = plt.subplots() labels = ["a", "b", "c", "d", "e"] line_collections = ax.plot(x, y.T, lw=4, alpha=0.2) interactive_legend = plugins.InteractiveLegendPlugin(line_collections, labels) plugins.connect(fig, interactive_legend) mpld3.display()
运行后得到的结果只有这个对象,看不到任何图形:
Out[7]: <IPython.core.display.HTML object>
我已经调用了mpld3.enable_notebook(),但还是没效果,有没有大佬能指点下问题出在哪?
内容来源于stack exchange
相关产品推荐
相关产品推荐

