【发布时间】:2023-03-12 00:27:01
【问题描述】:
感谢您对此问题的任何帮助。我正在尝试使用 matplotlib 制作子图,我编写的代码如下:
import networkx as nx
Fig, Axes = plt.subplots(nrows=1, ncols=2)
plt.tight_layout()
for i in range(0, NoOfVehicles):
Axes[i].set_aspect(1)
Axes[i].xaxis.set_major_formatter(mtick.NullFormatter())
Axes[i].yaxis.set_major_formatter(mtick.NullFormatter()
现在我如何在第一个情节中绘制一些东西,然后在第二个情节中绘制其他东西。
我想做
nx.drawing.nx_pylab.draw_networkx_nodes(GPlot[0].G, GPlot[0].Position, node_size=100, node_color=GPlot[0].Color)
在第一个情节和
nx.drawing.nx_pylab.draw_networkx_nodes(GPlot[1].G, GPlot[1].Position, node_size=100, node_color=GPlot[1].Color)
在第二个。
总之,这就是我想要做的:我希望第一组节点出现在 subplot(1,2,1) 中,第二组节点出现在 subplot(1,2,2) 中。但两者都出现在同一个情节中 (1,2,2)。
GPlot 只是一个包含 GraphPlot 类的 2 个对象的列表
class GraphForPlot:
def __init__(self):
self.G = nx.Graph()
self.Components = []
self.ActiveStatus = {}
self.Nodes = []
self.Position = {}
self.Color = []
【问题讨论】:
-
我不明白你在问什么。您希望代码做什么以及它在做什么?
-
我希望第一组节点出现在 subplot(1,2,1) 中,第二组节点出现在 subplot(1,2,2) 中。但两者都在同一个情节(1,2,2)
-
什么是
GPlot?您应该编辑您的问题以包含您之前的评论,以及GPlot是什么。
标签: python matplotlib networkx