iGraph python:如何向p添加轴线

2024-06-16 10:11:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个基于坐标的顶点位置图。有没有办法将轴添加到绘图中以查看顶点的最终位置?我找到了一种使用R(add frame=True to visual\ u style)的方法,但在python中似乎不起作用。你知道吗

在深入研究了源代码之后,我想我可能能够将默认抽屉更改为笛卡尔坐标系统,但是没有文档记录。我想我应该做的是

visual_style["drawer_factory"] = DescartesCoordinateSystem

但我得到了一个错误:

    ig.plot(self.g, png_pathname, **self.visual_style)
  File "<path_to_virtualenv>/local/lib/python2.7/site-packages/igraph/drawing/__init__.py", line 477, in plot
    result.save()
  File "<path_to_virtualenv>/local/lib/python2.7/site-packages/igraph/drawing/__init__.py", line 285, in save
    self.redraw()
  File "<path_to_virtualenv>/local/lib/python2.7/site-packages/igraph/drawing/__init__.py", line 269, in redraw
    plotter(ctx, bbox, palette, *args, **kwds)
  File "<path_to_virtualenv>/local/lib/python2.7/site-packages/igraph/__init__.py", line 3151, in __plot__
    drawer = drawer_factory(context, bbox)
TypeError: __init__() takes exactly 4 arguments (3 given)

是不是抽屉工厂漏掉了一个边界参数? 根据源代码,笛卡尔坐标系统需要contex、bbox和bounds [https://igraph.org/python/doc/igraph.drawing.coord.DescartesCoordinateSystem-class.html]

class Graph(GraphBase):
def __plot__(self, context, bbox, palette, *args, **kwds):
        drawer_factory = kwds.get("drawer_factory", DefaultGraphDrawer)
        if "drawer_factory" in kwds:
            del kwds["drawer_factory"]
        drawer = drawer_factory(context, bbox)
        drawer.draw(self, palette, *args, **kwds)

Tags: topathinselfvirtualenvplotinitfactory