如何解决Graphviz 集群对齐
我的图有 5 个集群(1 个垂直,4 个水平),
我想在这里纠正三件事,
- 所有水平簇都在右侧
- 每个水平集群与左侧集群上连接的节点处于同一高度(不得在上方或下方移动)
- 水平集群节点按照集群中的定义从 1 到 4 排序(非随机)
我尝试了分组和排名,但无法解决,
digraph {
graph[bgcolor = '#FDFDFD']
node[fontname = 'helvetica-bold',width = 1.5,height = 0.5,fontsize=12]
rankdir=TB;
subgraph cluster_main {
style=dashed; color= '#625a5a';
label='Steps for \n Scientometric Analysis'
graph[rankdir=TB]
node [shape=Box,style=filled,color=black,fillcolor = '#91cf60'];
a[group=g1,label = 'Section 1 \n Descriptive Analysis']
b[group=g2,label = 'Section 2 \n Intellectual Structure']
c[label = 'Section 3 \n Historiograph']
d[group=g3,label = 'Section 4 \n Conceptual structure']
e[label = 'Section 5 \n Thematic Map']
f[group=g4,label = 'Section 6 \n Social structure']
a -> b -> c -> d -> e -> f}
subgraph cluster_a {
color= '#625a5a';
node [shape=Box,style = filled,fillcolor = '#fee08b'];
a4[group=g1,label = 'Top manuscripts']
a3[group=g1,label = 'Most Productive \n Authors']
a2[group=g1,label = 'Most Cited \n References']
a1[group=g1,label = 'Main findings']}
subgraph cluster_b {
color= '#625a5a';
node [shape=Box,fillcolor = '#fee08b'];
b4[group=g2,label = 'Source \n coupling analysis']
b3[group=g2,label = 'Source \n co-citation analysis']
b2[group=g2,label = 'Article \n coupling analysis']
b1[group=g2,label = 'Article \n co-citation analysis']}
subgraph cluster_d {
color= '#625a5a';
node [shape=Box,fillcolor = '#fee08b'];
d4[group=g3,label = 'Title & Abstract \n Term Analysis']
d3[group=g3,label = 'Correspondence Analysis \n for both Keywords']
d2[group=g3,label = 'Author Keyword \n Co-occurrence & Growth']
d1[group=g3,label = 'Keyword-Plus \n Co-occurrence & Growth']}
subgraph cluster_f {
color= '#625a5a';
node [shape=Box,fillcolor = '#fee08b'];
f4[group=g4,label = 'Country \n Collaboration Network']
f3[group=g4,label = 'Edu \n Collaboration Network']
f2[group=g4,label = 'Author \n Collaboration Network']
f1[group=g4,label = 'Three Fields \n Plots']}
a -> {a1 a2 a3 a4}
b -> {b1 b2 b3 b4}
d -> {d1 d2 d3 d4}
f -> {f1 f2 f3 f4}
edge[style=invis]
a1 -> b1 -> d1 -> f1
a2 -> b2 -> d2 -> f2
a3 -> b3 -> d3 -> f3
a4 -> b4 -> d4 -> f4
}
解决方法
集群很难定位。你非常接近。我在 4 个水平集群周围添加了一个集群来围住它们,但这不是必需的。并更改了组。查找“已添加”一词以查找更改。
digraph {
graph[bgcolor = "#FDFDFD"]
graph [newrank=true] // added
node[fontname = "helvetica-bold",width = 1.5,height = 0.5,fontsize=12]
rankdir=TB;
subgraph cluster_main {
style=dashed; color= "#625a5a";
label="Steps for \n Scientometric Analysis"
graph[rankdir=TB]
node [shape=box,style=filled,color=black,fillcolor = "#91cf60"];
node [group=vert] // added
a[label = "Section 1 \n Descriptive Analysis"]
b[label = "Section 2 \n Intellectual Structure"]
c[label = "Section 3 \n Historiograph"]
d[label = "Section 4 \n Conceptual structure"]
e[label = "Section 5 \n Thematic Map"]
f[label = "Section 6 \n Social structure"]
a -> b -> c -> d -> e -> f}
subgraph cluster_a {
color= "#625a5a";
node [shape=box,style = filled,fillcolor = "#fee08b"];
a4[label = "Top manuscripts"]
a3[label = "Most Productive \n Authors"]
a2[label = "Most Cited \n References"]
a1[label = "Main findings"]}
subgraph cluster_b {
color= "#625a5a";
node [shape=box,fillcolor = "#fee08b"];
b4[label = "Source \n coupling analysis"]
b3[label = "Source \n co-citation analysis"]
b2[label = "Article \n coupling analysis"]
b1[label = "Article \n co-citation analysis"]}
subgraph cluster_d {
color= "#625a5a";
node [shape=box,fillcolor = "#fee08b"];
d4[label = "Title & Abstract \n Term Analysis"]
d3[label = "Correspondence Analysis \n for both Keywords"]
d2[label = "Author Keyword \n Co-occurrence & Growth"]
d1[label = "Keyword-Plus \n Co-occurrence & Growth"]}
subgraph cluster_f {
color= "#625a5a";
node [shape=box,fillcolor = "#fee08b"];
f4[label = "Country \n Collaboration Network"]
f3[label = "Edu \n Collaboration Network"]
f2[label = "Author \n Collaboration Network"]
f1[label = "Three Fields \n Plots"]
}
// added rank=same
{rank = same a -> {a1 a2 a3 a4} }
{rank = same b -> {b1 b2 b3 b4} }
{rank = same d -> {d1 d2 d3 d4} }
{rank = same f -> {f1 f2 f3 f4} }
edge[style=invis]
a1 -> b1 -> d1 -> f1
a2 -> b2 -> d2 -> f2
a3 -> b3 -> d3 -> f3
a4 -> b4 -> d4 -> f4
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。