python - 如何在 matplotlib 轴上绘制 iGraph 对象
问题描述
我有一个 iGraph 对象,我想将它绘制在 Matplotlib 轴上,
我的图表的代码是
from igraph import Graph, Layout
import igraph as ig
karate = Graph.Famous("Zachary")
layout = karate.layout_kamada_kawai()
visual_style={"bbox": (300, 300), "margin": 15, "layout": layout}
cl = karate.community_fastgreedy()
membership = cl.as_clustering().membership
pal = ig.drawing.colors.ClusterColoringPalette(len(membership))
karate.vs["color"] = pal.get_many(cl.as_clustering().membership)
karate.vs["size"] = 15
iGraph 文档说您可以在 Matplotlib 轴内绘图,使用,
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ig.plot(g, target=ax)
来源:https ://igraph.org/python/doc/tutorial/visualisation.html
然而,当我跑步时,
fig, ax = plt.subplots()
ig.plot(karate, **visual_style, target=ax)
我收到以下错误,
TypeError:预期的 str、字节或 os.PathLike 对象,而不是 AxesSubplot
谁能解释我做错了什么?谢谢!
解决方案
推荐阅读
- python - 拥有索引数组并希望从数据框中获取其行
- pandas - Matplotlib:仅选定值的条形图
- at-command - ESP8266-01 根本不工作,带有 AT 固件或闪烁草图
- pyspark - Spark 自联接(层次结构)
- r - R Script Power Query:在 Power BI 中读取为数字的新字符列
- swiftui - 是否有更好的方法在 SwiftUI 中对浮动工具栏进行建模,以响应 @EnvironmentObject 更改而无需重新渲染整个应用程序?
- php - 注意:未定义的变量:/opt/lampp/htdocs/pathToFile 中的 $_SERVER #LineNumber
- spring - Spring Batch 应用程序 - 在调用 Spring Boot 应用程序时获取空指针应用程序
- python - 如何从 Stack Exchange API 以 JSON 格式而不是 HTML 格式检索数据?
- swift - 搜索时搜索视图返回空白