[solved] Same attribute value for all elements of a graph?

Hello
Is it possible to set the same attribute value for all elements of a graph?
(Example: same fontsize)

I saw https://graphviz.org/docs/graph/
But how can we do it?
graph [fontsize=“20pt”] { … makes an error.

Thanks by advance for your help.

I believe that the “pt” was a fairly recent improvement but before is was graph [fontsize=20].
What version of Graphviz are you using? (type dot -V)

I’m using graphviz with

graph [fontsize=20] makes an error.

You can see an example

the attributes need to be within the braces.
Like so:

graph { graph [fontsize=20] 
    Placement [shape=polygon]
   Placement  -- replaced
}

or with arrows (directed)

digraph { graph[fontsize=20] 
    Placement [shape=polygon]
  Placement  -> replaced
}
graph { graph [fontcolor="red"] 
    a [shape=polygon]
b [fontcolor="red"]
}

[dot]
graph { graph [fontcolor=“red”]
a [shape=polygon]
b [fontcolor=“red”]
}
[/dot]

Doesn’t work in visual, with js or here.
I put fontcolor to see it easily.

I want ‘a’ to be red also.

See in visual

You are correct. fontcolor can apply to four object types and you need to declare the (up to four) defaults separately.

graph { 
  graph [fontcolor="blue" label="my graph"] 
  node [fontcolor=green]
  edge [fontcolor=pink label="\E"]
 subgraph cluster90 {
  graph [label="gathered" fontcolor=purple]
    a [shape=polygon]
   b [fontcolor="red"]
   a -- b
 }
}
1 Like