Stephane Rolland
Stephane Rolland

Reputation: 39926

How to set default node shape to box instead of oval?

I have some long labels in my graph written in dot language. As a result, (the default shape being oval) I have some not very practical thin really long oval in my graph which take much space.

I would like to set the default shape to box for all my nodes, unless specified otherwise.

I have seen the node notation, but it requires to list any node impacted by the styles.

Is it possible in dot language ?

Upvotes: 41

Views: 11072

Answers (3)

pfalcon
pfalcon

Reputation: 7007

Mind that you also can specify default node shape (or any other attribute) on the dot tool command line using -N switch, e.g.:

dot -Nshape=box graph.dot -Tpng -o graph.png

Upvotes: 7

cn123h
cn123h

Reputation: 2332

Btw, if you only need to change part of the nodes, you can use a subgraph like this:

digraph ExampleGraph
{
  {
    // only change a and d
    node [shape="box"]; a; d;
  }
    a -> b -> c -> d;
}

Upvotes: 9

Stephane Rolland
Stephane Rolland

Reputation: 39926

using the node notation without listing the impacted nodes make the node shape style applied by default.

digraph ExampleGraph
{
    node [shape="box"];

    a -> b -> c -> d;
}

Upvotes: 74

Related Questions