"""单独渲染项目节点的两条自回边,便于核对 包含/续签自 关系。""" from __future__ import annotations import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt OUT = r"E:\CODE\knowledge_agent\meta_graph_project_self_loops.png" def main() -> None: fig, ax = plt.subplots(figsize=(7, 5)) ax.scatter([0], [0], s=3600, c="#4C9F70", edgecolors="white", linewidths=2) ax.text(0, 0, "项目", ha="center", va="center", color="white", fontsize=14, family="Microsoft YaHei") items = [ ("包含\n(层级序号 父→子)", "#2E75B6", 0.55, 0.38), ("续签自\n(续签前项目编号)", "#C55A11", -0.55, -0.38), ] for label, color, rad, dy in items: ax.annotate( "", xy=(0.16, dy), xytext=(-0.16, dy), arrowprops=dict( arrowstyle="-|>", color=color, lw=3, connectionstyle=f"arc3,rad={rad}", mutation_scale=22, ), ) ax.text(0, dy + (0.58 if dy > 0 else -0.58), label, ha="center", va="center", fontsize=10, family="Microsoft YaHei", color=color) ax.set_xlim(-1.6, 1.6) ax.set_ylim(-1.6, 1.6) ax.set_aspect("equal") ax.axis("off") ax.set_title("项目自回边:包含 / 续签自", family="Microsoft YaHei", fontsize=15) fig.tight_layout() fig.savefig(OUT, dpi=150, bbox_inches="tight") print(OUT) if __name__ == "__main__": main()