How to underline text as part of a label? - graphviz

Following is code using dot language.
subgraph cluster1
{
node[style=filled];
color=blue;
b0->b1;
label ="Tada"; // I want this to show as underlined.
}

You can use HTML-like labels and the <u> tag:
digraph cluster1
{
node[style=filled, color=blue];
b0->b1;
label = <<u>Tada</u>>; // I want this to show as underlined.
}
This is the result:
Note that your color=blue statement wasn't applied to any element. I moved it into node.
As pointed out in the comments, this currently only works for svg output. I tried with png and pdf on my Mac running 10.14.6 and they weren't underlined.

Related

Graphviz: Distinct colors for xlabel and nodelabel

Is it possible to have distinct font colors for xlabel and node label in Graphviz?
digraph {
"complete" [xlabel="complete", label="complete", fontcolor=red];
}
Only way I know of is a bit of a kludge. Use html labels for the label or xlabel:
digraph {
"complete" [xlabel=<<font color="green">Xcomplete</font>>
label="complete", fontcolor=red];
}
produces this:

How to have multiple rows in a node without setting `rankdir` nor using html tags

I need to plot nodes which have two rows. The top row is node name, and the bottom row is a condition. I am currently using the html-style table tag to achieve this. However, somehow I dislike this way. So, I am wondering if there is a more concise way without using html-style tags to do this. Note that I don't want to change rankdir=TB to rankdir=LR.
An example of my current approach, including code and output, is attached below. Thank you in advance.
digraph G {
node [shape=Mrecord]
aNode [ label=<
<table border='0'>
<tr><td bgcolor='gray'>nodeName</td></tr>
<tr><td>condition</td></tr></table>
> ];
}
Putting {} around the text in your label will change the direction of the record separators.
digraph {
graph [rankdir=TB];
node [shape=Mrecord];
item [label="{one | two}"];
}

Get rid of "_anonymous_0" tooltips in SVG with GraphViz

I generate SVGs using Graphviz. When embedded in HTML, the nodes, edges and arrows show an "_anonymous_0" tooltip. Can I get rid of these from within GraphViz?
Found by trial and error :-)
digraph "my title" {
tooltip=" "
node [tooltip=" "]
edge [tooltip=" "]
...
}
disables the automatic generation of tooltips.
an empty string
tooltip=""
does not(!) disable the generation.
If your dot source start something like this:
digraph {
it may help to use the following:
digraph "" {
It looks like the name of the graph (digraph mygraph { ) is transformed to a title element (<title>mygraph</title>). If you omit the name, *anonymous_0* is used instead. But if "" is used, no title element is being created.
There may be a better solution to this though...

How do I set the Cluster font attributes in Graphviz?

I am able to successfully change the edge font, and the node font, but my attempts to change the cluster labels have no affect. Can someone point me in the right direction?
I have tried labelfontname=, fontname= (on the edge and the node), but can't seem to find the magic formula for cluster labels.
fontname is working for cluster labels.
Here's an example with illustration - it's quite simple, just set it before setting the content of the label.
digraph g{
node[fontname="Impact"];
subgraph cluster0 {
"Cluster node";
fontname="Courier";
label="Cluster label";
}
fontname="Arial";
label="Graph Label";
}
The result:

How do you center a title for a diagram output to SVG using dot?

So far I tried this line but dot keeps pushing it aside making room for my nodes (pushes it to the right):
_diagram_info [shape="plaintext", label="My Diagram\l", fontsize=13]
Is there a way to center the label by pos, using dot?
That's how I'd add a title for a graph:
digraph {
// nodes, edges, subgraphs
...
// title
labelloc="t";
label="My Diagram";
}
This will add a centered title to the top of the graph.
The same syntax can also be used for subgraphs.

Resources