Graphviz 集群对齐

如何解决Graphviz 集群对齐

我的图有 5 个集群(1 个垂直,4 个水平),

我想在这里纠正三件事,

  1. 所有水平簇都在右侧
  2. 每个水平集群与左侧集群上连接的节点处于同一高度(不得在上方或下方移动)
  3. 水平集群节点按照集群中的定义从 1 到 4 排序(非随机

我尝试了分组和排名,但无法解决

Resulting Graph

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
 }

给予:
enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?