0
私は、NetworkXを使用してPython 2.7で動作する以下のコードを持っています。NetworkX Degreeのヒストグラム - Python 2とPython 3
plt.hist(nx.degree(G).values())
plt.xlabel('Degree')
plt.ylabel('Number of Subjects')
plt.savefig('network_degree.png') #Save as file, format specified in argument
私は、Python 3の下で、この同じコードを実行してみてください
、私は次のエラーを取得する:
Traceback (most recent call last):
File "filename.py", line 71, in <module>
plt.hist(nx.degree(G).values())
File "/Users/user/anaconda/envs/py3/lib/python3.5/site-packages/matplotlib/pyplot.py", line 2958, in hist
stacked=stacked, data=data, **kwargs)
File "/Users/user/anaconda/envs/py3/lib/python3.5/site-packages/matplotlib/__init__.py", line 1812, in inner
return func(ax, *args, **kwargs)
File "/Users/user/anaconda/envs/py3/lib/python3.5/site-packages/matplotlib/axes/_axes.py", line 5960, in hist
x = _normalize_input(x, 'x')
File "/Users/user/anaconda/envs/py3/lib/python3.5/site-packages/matplotlib/axes/_axes.py", line 5902, in _normalize_input
"{ename} must be 1D or 2D".format(ename=ename))
ValueError: x must be 1D or 2D
I基本的に、それはちょうどそうのような程度ノードのヒストグラムをプロット私はかなり単純なコードになると期待していたものを使って、今はPython 3で混乱し始めています。何が変わったの?
のサポートだけでHTTPSをマスターする合併しました: //github.com/matplotlib/matplotlib/pull/6787 – tacaswell