【发布时间】:2017-09-02 00:04:10
【问题描述】:
我最近重新安装了 matplotlib,我注意到我几个月前编写的代码(功能齐全)使用 networkx 生成图形输出,现在在控制台上输出错误。我得到的错误如下详述。
C:\Python36\lib\site-packages\networkx\drawing\nx_pylab.py:126: MatplotlibDeprecationWarning: pyplot.hold is deprecated.
Future behavior will be consistent with the long-time default:
plot commands add elements without first clearing the
Axes and/or Figure.
b = plt.ishold()
C:\Python36\lib\site-packages\networkx\drawing\nx_pylab.py:138: MatplotlibDeprecationWarning: pyplot.hold is deprecated.
Future behavior will be consistent with the long-time default:
plot commands add elements without first clearing the
Axes and/or Figure.
plt.hold(b)
C:\Python36\lib\site-packages\matplotlib\__init__.py:917: UserWarning: axes.hold is deprecated. Please remove it from your matplotlibrc and/or style files.
warnings.warn(self.msg_depr_set % key)
C:\Python36\lib\site-packages\matplotlib\rcsetup.py:152: UserWarning: axes.hold is deprecated, will be removed in 3.0
warnings.warn("axes.hold is deprecated, will be removed in 3.0")
Traceback (most recent call last):
File "C:\Users\lukec\Dropbox\University\Year 2 Semester 2\ICS2210 Data Structures and Algorithms II\Assignment\launcher.py", line 33, in <module>
graph.draw()
File "C:\Users\lukec\Dropbox\University\Year 2 Semester 2\ICS2210 Data Structures and Algorithms II\Assignment\graph.py", line 122, in draw
nx.drawing.nx_pydot.write_dot(G, "graph.dot")
File "<decorator-gen-232>", line 2, in write_dot
File "C:\Python36\lib\site-packages\networkx\utils\decorators.py", line 220, in _open_file
result = func(*new_args, **kwargs)
File "C:\Python36\lib\site-packages\networkx\drawing\nx_pydot.py", line 43, in write_dot
P=to_pydot(G)
File "C:\Python36\lib\site-packages\networkx\drawing\nx_pydot.py", line 175, in to_pydot
import pydotplus
ModuleNotFoundError: No module named 'pydotplus'
程序仍然可以正常运行,但是我得到了正确的计算和图形输出,唯一的区别是 matplotlib 看起来不同:
我的问题是:
这可能是因为 matplotlib 最近被 更新了,networkx 似乎正在使用它的东西 过时了吗? (我相信上个月更新了 Matplotlib)。会不会 从我的代码?有什么办法可以防止这些错误发生吗?
感谢您的帮助。
【问题讨论】:
标签: python matplotlib networkx