Matplotlib的NetworkX错误 [英] NetworkX Bug with Matplotlib

查看:116
本文介绍了Matplotlib的NetworkX错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近重新安装了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是在上个月更新的).可能是 从我的代码?我有什么办法可以防止这些错误?

感谢您的帮助.

解决方案

networkx 的最新发布日期是2017年1月11日 >

除了pydotplus消息外,您收到的所有消息似乎都警告您在不久的将来某些当前命令将不起作用(并提供有关如何立即访问这些将来的命令的说明).我不知道pydotplus.我不认为这与matplotlib有关.

是的,这是因为进行了更新.这应该没问题,但是也许networkx的下一版本需要与新的matplotlib一起使用.

我相信您会在此问题上找到摆脱这些警告的说明:如何抑制matplotlib警告?

I've recently reinstalled matplotlib, and I've noticed that code which I'd written some months ago (which was fully functional), which uses networkx to generate a graph output, is now outputting errors on the console. The errors I get are detailed below.

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'

The program still functions correctly however, I get the right calculations and graphic outputs as I did before, the only difference is a different-looking matplotlib:

My question is:

Could this be due to the fact that matplotlib has recently been updated, and networkx seems to be using things from it which are outdated? (Matplotlib was updated last month I believe). Could it be from my code? Is there anything I can do to prevent these errors?

I appreciate any help.

解决方案

The date for the newest release of matlplotlib is Feb 20 2017.

The date for the newest release of networkx is Jan 11 2017

Aside from the pydotplus message, the messages you're getting all seem to be warnings that in the near future some current commands won't work (and gives instructions for how to access those future commands right now). I don't know about pydotplus. I don't think it's matplotlib-related.

So yes, this is because of the update. It shouldn't be a problem, but perhaps the next version of networkx will need to work with the new matplotlib.

I believe you will find instructions for getting rid of these warnings at this question: How to suppress matplotlib warning?

这篇关于Matplotlib的NetworkX错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆