虽然在Ubuntu上生成iGraph绘图没有问题,但我在cygwin上得到了以下错误:
$ python
Python 2.7.8 (default, Jul 28 2014, 01:34:03)
[GCC 4.8.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from igraph import Graph, plot
>>>
>>> g = Graph([(0,1), (0,2), (2,3), (3,4), (4,2), (2,5), (5,0), (6,3), (5,6)])
>>> g.vs["name"] = ["Alice", "Bob", "Claire", "Dennis", "Esther", "Frank", "George"]
>>>
>>> layout = g.layout("kk")
>>> plot(g, layout = layout)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/igraph/drawing/__init__.py", line 475, in plot
result.show()
File "/usr/lib/python2.7/site-packages/igraph/drawing/__init__.py", line 327, in show
"on this platform: %s" % plat)
NotImplementedError: showing plots is not implemented on this platform: CYGWIN_NT-6.1-WOW
>>>有没有人成功地在雪佛兰上制作了iGraph地块?
编辑:文档声明:
绘图依赖于pycairo库,它为流行的Cairo库提供Python绑定。这意味着如果您没有安装pycairo,您将无法使用绘图功能。
我将检查我的py2cairo安装是否有问题。
请注意,其他iGraph功能在cygwin上运行得很好:
$ python
Python 2.7.8 (default, Jul 28 2014, 01:34:03)
[GCC 4.8.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from igraph import Graph, plot
>>> g = Graph()
>>> print(g)
IGRAPH U--- 0 0 --
>>> g = Graph([(0,1), (0,2), (2,3), (3,4), (4,2), (2,5), (5,0), (6,3), (5,6)])
>>> g.vs["name"] = ["Alice", "Bob", "Claire", "Dennis", "Esther", "Frank", "George"]
>>> g.vs["age"] = [25, 31, 18, 47, 22, 23, 50]
>>> g.vs["gender"] = ["f", "m", "f", "m", "f", "m", "m"]
>>> g.es["is_formal"] = [False, False, True, True, True, False, True, False, False]
>>> g.es[0]["is_formal"] = True
>>> g.es[0]
igraph.Edge(<igraph.Graph object at 0xffcb542c>, 0, {'is_formal': True})
>>> g["date"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'Attribute does not exist'
>>> g["date"] = "2015-05-31"
>>> g["date"]
'2015-05-31'
>>> g.degree()
[3, 1, 4, 3, 2, 3, 2]
>>> g.edge_betweenness()
[6.0, 6.0, 4.0, 2.0, 4.0, 3.0, 4.0, 3.0, 4.0]
>>> g.vs[2].degree()
4
>>>环境:
发布于 2015-06-05 20:22:34
您的计算机上的py2cairo可能没有什么问题,但是您可以自己测试它。尝试plot(g, "test.png", layout=layout) -这将保存在一个文件中,而不是显示它。您看到的错误消息由igraph抛出,因为它无法确定如何指示操作系统在窗口中显示PNG文件(其中保存了绘图)。
用于显示情节的命令存储在名为apps.image_viewer的配置变量中。您可以按以下方式修改它:
>>> from igraph import Configuration
>>> cfg = Configuration.instance()
>>> cfg["apps.image_viewer"] = "start"如果将PNG文件的名称传递给默认图像查看器,这可能会起到很大的作用,因为Windows上的start命令应该打开默认的图像查看器。如果它有效,您可以通过将以下内容写入cfg.filename指向的文件来持久化更改
[apps]
image_viewer=start就其价值而言,in中用于确定在特定操作系统上使用哪个图像查看器(如果不存在apps.image_viewer键)的部分是在名为get_platform_image_viewer()的函数的igraph/configuration.py中。这个函数使用platform.system()来确定您使用的是哪个操作系统。如果您能让我知道platform.system()在您的Python中打印了什么,我将提交一个补丁,使in能够像对待Windows一样对待Cygwin。
https://stackoverflow.com/questions/30559041
复制相似问题