我的问题是在 Pydot 中如何设置集群中的节点顺序?
我的代码是
import pydot
graph = pydot.Dot(graph_type='digraph', rankdir="LR")
graphlegend = pydot.Cluster(graph_name="legend", label="Legend", fontsize="15", color="red", style="filled", fillcolor="lightgrey")
legend1 = pydot.Node("Sample", style="filled", fillcolor="Tomato", shape="diamond", rank="same"); graphlegend.add_node(legend1)
legend2 = pydot.Node('a', style="filled", fillcolor="LightGoldenrod", shape="Mrecord", label="Protein", rank="same"); graphlegend.add_node(legend2)
node_c = pydot.Node("ff", style="filled", fillcolor="#9ACEEB", shape="square"); graph.add_node(node_c)
graph.write_png('Sample_diagraph.png')
我希望集群“legend”和“node_c”以垂直顺序排列,但“graphlegend”集群中的 2 个节点(legend1 和 legend2)水平排列成一行。我尝试使用 rank=same 但不起作用你能帮帮我吗?