Venn Diagram in Dot
Asked Answered
D

0

7

I have been trying to implement a Venn Diagram in Dot. Whilst Venn Diagrams probably aren't that useful in Dot, it's mostly so I can use it as a very basic building block.

I have provided some ways that I have tried to do this:

graph G {
    subgraph cluster0 {
        color=white;

        subgraph cluster0 {
            label="1";
            color=black;
            a;
            b;
        }

        subgraph cluster1 {
            label="2";
            color=black;
            b;
            c;
        }
    }


    subgraph cluster1 {
        color=white;

        subgraph cluster2 {
            label="1";
            color=black;
            d;
        }

        subgraph cluster3 {
            label="1+2";
            color=black;
            e;
        }

        subgraph cluster4 {
            label="2";
            color=black;
            f;
        }
    }


    subgraph cluster2 {
        color=white;

        subgraph cluster5 {
            label="1";
            color=black;
            g;

            subgraph cluster6 {
                label="2";
                color=black;
                h;
            }
        }

        subgraph cluster6 {
            label="2";
            color=black;
            i;
        }
    }

    a -- d -- g [penwidth=0];
    b -- e -- h [penwidth=0];
    c -- f -- i [penwidth=0];
}

Producing:

three example Venn diagrams

These all have problems:

  • The first says b is in 1, but not 2. When it should be in both.
  • The second looks like it's separate from 1 and 2. And can be hard to show it's both.
  • The third is almost perfect IMO, it just requires the two 2 sub-graphs to join together.

To prevent an XY problem, I have:

  • two servers,
  • a docker swarm between the two servers, and
  • three applications. Located at:

    • One is on the first server, not in the docker swarm.
    • One is on the first server in the docker swarm.
    • One is on the second server in the docker swarm.

Leading to:

graph G {
    subgraph cluster0 {
        color=white;

        subgraph cluster0 {
            label="Server1";
            color=black;
            a;

            subgraph cluster0 {
                label="Docker";
                b;
            }
        }

        subgraph cluster1 {
            label="Server2";
            color=black;

            subgraph cluster0 {
                label="Docker";
                c;
            }
        }
    }


    subgraph cluster1 {
        color=white;

        subgraph cluster0 {
            label="Server1";
            color=black;

            d;
        }

        subgraph cluster1 {
            label="Docker";
            color=black;

            subgraph cluster0 {
                label="Server1";
                e;
            }

            subgraph cluster1 {
                label="Server2";
                f;
            }
        }
    }

    a -- d [penwidth=0];
    b -- e [penwidth=0];
    c -- f [penwidth=0];
}

Two different ways to display the docker server grouping

Dextrorotation answered 7/3, 2018 at 14:36 Comment(3)
I am also looking for solution to this questionBravura
I usually just use images, here's a collection of all 2set and 3set venn diagrams: github.com/Ace-Cassidy/Venn-Diagram-PicturesIndore
@Indore It would be easier for people to see if you update the readme to show the output :)Dextrorotation

© 2022 - 2024 — McMap. All rights reserved.