style=invis / style=invisible inconsistency/weirdness
While exploring the documentation for information on style=invis
(see #2422 (closed)), @truenorth and I discovered that a second "invisible" style, style=invisible
, was also documented as a Node style (only). In further exploration, I discovered that both styles not only existed, but had different meanings — for both nodes and edges. The following dot code demonstrates those inconsistencies:
digraph G {
N1[label="Node with image" shape=box image="usershape.svg"];
N2[label="Node with image" shape=box image="usershape.svg"];
N1a[label="Node with image" shape=box image="usershape.svg" style="invis"];
N2a[label="Node with image" shape=box image="usershape.svg" style="invisible"];
N1 -> N1a[label="add\nstyle=invis"];
N2 -> N2a[label="add\nstyle=invisible"];
N3[shape=circle];
N3a[label="Edge with xlabel" shape=box];
N4[shape=circle];
N4a[label="Edge with xlabel\nand style=invis" shape=box];
N5[shape=circle];
N5a[label="Edge with xlabel\nand style=invisible" shape=box];
N3 -> N3a[xlabel="🔥"];
N4 -> N4a[xlabel="🔥" style=invis];
N5 -> N5a[xlabel="🔥" style=invisible];
}
Steps to reproduce
-
cd /path/to/graphviz/tests/
(the code uses theusershape.svg
file from that directory) - Save the code above as e.g.
invis_test.dot
dot -Tpng invis_test.dot -oinvis_test.png
Actual Behaviour
Dot will produce this PNG:
While style=invis
causes the styled node/edge to completely disappear, along with all of its associated "decoration", style=invisible
causes only partial invisibility: A node's shape and label are hidden, but its image=
content remains. The line for an edge isn't drawn, but its arrowhead and xlabel are.
OS/Graphviz Version
Most likely all, but tested on Fedora Linux 39, using both distro-built dot - graphviz version 8.1.0 (20230707.0739)
and locally-built dot - graphviz version 10.0.0~dev.20231228.2101 (20231228.2101)
Additional info
As I mentioned in #2522 (moved), my best guess for what's going on in the node situation is that gvrender.c
will set the pen style to PEN_NONE
if either "invis" or "invisible" is set:
https://gitlab.com/graphviz/graphviz/-/blob/main/lib/gvc/gvrender.c#L501
but shapes.c
only supports "invis" to set the shape's overall style as INVISIBLE
:
https://gitlab.com/graphviz/graphviz/-/blob/main/lib/common/shapes.c#L452
(That being said, I hadn't yet realized that style=invisible
also works on edges, and also works differently than style=invis
on edges, as well. So, the situation may be more complex / involve more code than just what's in gvrender.c
and shapes.c
.)