简体   繁体   English

graphviz节点中的Python节点形状-饼图

[英]graphviz Python Node Shapes-Pie Chart in a node

I am writing a Python script to generate a network graph using graphviz. 我正在编写一个Python脚本,以使用graphviz生成网络图。 Some of my nodes represents injection into a network and I am wondering if it is possible to have a Pie-Chart inside some of the nodes. 我的某些节点表示注入到网络中,我想知道是否有可能在某些节点内使用饼形图。

Python code for a simple two node network is following: 一个简单的两节点网络的Python代码如下:

import graphviz as gv

g1 = gv.Graph(format='svg')
g1.node('A')
g1.node('B')
g1.edge('A', 'B')

filename = g1.render(filename='img/g1')

I let the PyGraphViz implementation up to you. 我让PyGraphViz实现交给您。 But to answer to the core of your question, since graphviz 2.30, you can use the wedged style for nodes, to achieve the desired result. 但是要回答您问题的核心,从graphviz 2.30开始,您可以对节点使用wedged样式,以达到所需的结果。 Here is an example in plain dot: 这是一个以纯圆点表示的示例:

digraph G {
  {
    node [shape=circle style=wedged fillcolor="red;0.3:green;0.6:orange"]
    A
    node [style=solid fillcolor="white" ]
    B
    C
  }

B -> A
B -> C
}

点饼图节点

The list of colors is expressed as a colon separated list. 颜色列表表示为冒号分隔的列表。 The value after the **semi-colon* in the weight of the given color. 以给定颜色的重量表示的分号*之后的值。 The sum of all weights must be equal to 1.0. 所有权重的总和必须等于1.0。 See the colorList attribute 请参阅colorList属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM