Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control spacing in twopi (Graphviz)

Tags:

graphviz

I'm a newbie with Graphviz, and I'm trying to draw a tree centered in an entity (I'm using the twopi command).

  • If I put overlap=true it overlaps even if it has a lot of space aroud the overlapped labels.
  • If I put overlap=false, labels become too small.

How can I have the first situation without overlapping?

Complete code:

digraph g {
    graph [ fontname = "Helvetica",
        fontsize = 10,
        size = "500,500",
        splines=true,
        overlap=false,
        ratio=.5 ];
    node [  shape = plaintext,
        fontname = "Helvetica" ];

    root="owl:Thing";
    "owl:Thing" -> "Work";
    "Work" -> "WrittenWork";
    "Work" -> "Software";
    "Work" -> "Website";
    "Work" -> "Film";
    "owl:Thing" -> "Agent";
    "Agent" -> "Organisation";
    "Organisation" -> "Non-ProfitOrganisation";
    "Organisation" -> "GeopoliticalOrganisation";
    "Organisation" -> "SambaSchool";
    "Agent" -> "Person";
    "Person" -> "Athlete";
    "Person" -> "OfficeHolder";
    "Person" -> "Astronaut";
    "Person" -> "Philosopher";
    "Person" -> "Architect";
    "owl:Thing" -> "Drug";
    "owl:Thing" -> "Place";
    "Place" -> "SiteOfSpecialScientificInterest";
    "Place" -> "PopulatedPlace";
    "PopulatedPlace" -> "Country";
    "PopulatedPlace" -> "Continent";
    "PopulatedPlace" -> "Atoll";
    "Place" -> "ProtectedArea";
    "Place" -> "ArchitecturalStructure";
    "Place" -> "HistoricPlace";
    "Place" -> "NaturalPlace";
    "NaturalPlace" -> "Mountain";
    "NaturalPlace" -> "Volcano";
    "NaturalPlace" -> "MountainRange";
}

Thank you,

Alessio

like image 746
Alessio Palmero Aprosio Avatar asked Feb 18 '23 06:02

Alessio Palmero Aprosio


1 Answers

For this particular graph, you may use overlap=true and then increment ranksep until no labels overlap anymore. ranksep=1.3 seems to be a good value.

twopi output with ranksep applied

like image 169
marapet Avatar answered Feb 20 '23 21:02

marapet