我的问题是在 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,但不起作用。请问你能帮忙吗?