0

pylabnetworkxを使用して有向グラフ を描画しようとしています。

以下は小さなデモスクリプトとそれが生成するエラーです(そして、pylabによって作成されたウィンドウは空です)。

グーグルは、このエラーがすでに2008年にmathplotlibのsvnで修正されることになっていたことを示しています。

誰かが私を正しい方向に向けることができますか?


このスクリプト:

import pylab
import networkx as nx

def Working_with_graphs_using_networkx():
    fig = pylab.figure()
    g = nx.Graph(name = "graph")
    pylab.title(g.name)
    g.add_node("John")
    g.add_node("Maria")
    g.add_edge("John", "Maria")
    pos = nx.spring_layout(g)
    nx.draw(g, pos)

if __name__ == "__main__":
    Working_with_graphs_using_networkx()
    pylab.show()

このエラーを生成します(cygwinのPython 2.6で):

$ python demo_SeqBase.py
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1410, in __call__
    return self.func(*args)
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_tkagg.py", line 236, in resize
    self.show()
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_tkagg.py", line 239, in draw
    FigureCanvasAgg.draw(self)
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_agg.py", line 401, in draw
    self.figure.draw(self.renderer)
  File "/usr/lib/python2.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/matplotlib/figure.py", line 884, in draw
    func(*args)
  File "/usr/lib/python2.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 1983, in draw
    a.draw(renderer)
  File "/usr/lib/python2.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/matplotlib/collections.py", line 238, in draw
    self._linewidths, self._linestyles, self._antialiaseds, self._urls)
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_agg.py", line 84, in draw_path_collection
    return self._renderer.draw_path_collection(*kl, **kw)
IndexError: Unexpected SeqBase<T> length.
4

0 に答える 0