How to strike-through text in dot language (graphviz) - graphviz

I am trying to find out how can I strike-through some text in my nodes in dot based graphviz diagrams?
I checked out on this page, but couldn't figure out:
http://www.graphviz.org/doc/info/attrs.html
Googling around didn't help as well.
Consider this diagram, these are basically bug numbers from a bugzilla. The red nodes represent closed bugs, but I do not want to color code them like this. Obviously striken-through 511272 is more intuitive than a red colored node 511272.
If anyone knows how to strike-through text inside nodes, please share.
thanks,
Shobhit

Graphviz does not have a styling of its own to do this, but since it is Unicode you can use the technique with combining characters and "combining long stroke overlay" (U+0336) that the wikipedia article on strikethrough suggests:
In plain text scenarios where markup cannot be used, Unicode offers a number of combining characters that achieve similar effects.
The "long stroke overlay" (U+0336) results in an unbroken stroke
across the text,
Separate: A̶B̶C̶D̶E̶F̶G̶H̶I̶
Combined: A̶B̶C̶D̶E̶F̶G̶H̶I̶
This graph:
digraph G {
a [label="1̶2̶3̶4̶5̶"]
b [label="54321"]
a->b
}
Renders this png output with graphviz 2.23.6:

Aother option is to use HTML-like labels:
digraph G {
a [label=<<s>12345</s>>]
b [label="54321"]
a->b
}

Related

Graphviz with nodes and edges in Russian: edge label has offset and Node is enlarged

I'm drawing diagram with graphviz. I set node and edge labels in Russian. Nodes with Russian labels are much larger than nodes with English labels with the same length. Also edge labels in Russian have offset that labels in English doesn't have.
I tried to use different graphviz tools such as: viz-js.com, Atom editor with graphviz plugin, gvedit. Only gvedit provides correct result, but I can't use it.
Here is sample code:
digraph D {
Anton -> Антон [label="Метка"]
Anton -> Bob [label="Label"]
}
Result is:
Not really an solution / answer but some observations and it is a bit long for a comment.
I tried the given file directly with dot version 2.38.0 (20140413.2041) and got as result:
I also tried with version version 2.40.1 (20161225.0304) and got the same result.
So I think the underlying dot program is working correct.
I also tried http://www.webgraphviz.com/ but here I get the message:
Warning: :3: string ran past end of line Error: :3: syntax error near line 3
and the resulting image is even worse:
So here it looks like the used input encoding is not correct, this might also be the case with the tools OP used.

Increasing rank spacing in graphviz

I have a graph laid out using D3 graphviz. It's laying out in a pretty dense way, and I'd like it to use more of the width of the screen.
I have tried adjusing the ranksep and the ratio, but neither seem to have any effect. I've also tried changing the node border, to no effect. Changing the edge minlength just makes the edges look floppy. I can try giving every node an invisible child, but that seems like a horrible hack.
For clarity, by rank, I mean the horizontal spacing between the columns of nodes. (The graph is laid out left to right.)
Ideally I'd be able to give it an aspect ratio and it'd make the most of that space to lay out the graph in a way that doesn't need too much acrobatics.
Am I missing something obvious?
I may well be using the options incorrectly
or the D3 graphviz implementation may not have those features?
Is there no good way to do this?
I have added :
size = "16.66,8.33!"; // 1200x600 at 72px/in, "!" to force
ratio = "fill"; // see https://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:ratio
at the beginning of the graph declaration (just after digraph G {).
It renders a wider output.
Have a try and tell.

GraphViz Dot. How to distribute elements around a boxed size?

I have a dot graphviz file that geneates the following output:
http://www.qlands.com/other_files/test.png
However the output is organized vertically. If I setup the size to be for example 8.27 inches; How can I distribute the elements around a box of 8.27 x 8.27 inches?
Your graph is a directed graph layed out with dot from left to right, and the first rank contains many nodes which results in a very high image.
The main tool to break up graphs with this problem is unflatten:
unflatten is a preprocessor to dot that is used to improve the aspect
ratio of graphs having many leaves or disconnected nodes. The usual
layout for such a graph is generally very wide or tall. unflatten
inserts invisible edges or adjusts the minlen on edges to improve
layout compaction.
You may combine this with other tools and techniques to get the result you want:
Use the unflatten utility - please see this answer for a detailed example using unflatten.
Use invisible edges to introduce new ranks (basically what unflatten does automatically, but with human inspiration... example also here)
If you need the output to be of this exact size, be sure to understand graphviz's various attributes which have an impact on it, such as size, margin, ratio... (see also this and yet another answer providing details)
Finally, you could simply use a different layout (neato for example)

Display labels in line with the edge when using Graphviz

I am using Graphviz 2.30. Horizontal positioning for labels works out, but in a few cases, a modified angle would be desired.
For instance, I tried various values for angle here but without any effect:
ABB -> ABACUS[label="applied", fontname="Arial", fontsize=15, labelangle=110];
How can I display labels in line with (i.e. parallel to) the edge when using a Graphviz digraph.
The entire digraph will not be posted due to an NDA. In addition, the rotation will be applied only to a few labels.
I have read similar threads like this or another (or a thread about alignment for instance) but without any help regarding my issue.
Using dot2latex allows you to specify lblstyle attribute. The value of lblstyle is used by PGF/TikZ in pdf generation.
One can specify parallel labels like this:
digraph G {
edge [lblstyle="above, sloped"];
a -> b [label="ab"];
b -> c [label="bc"];
c -> a [label="ca"];
}
To generate the pdf
$ dot2tex --tikzedgelabel file.dot > file.tex
$ pdflatex file.tex
The result is
Edit: another answer found an option that now exists to align text with edges.
Your best option may be to export the graph as an SVG and use Illustrator or Inkscape to fine-tune it. This is only practical when producing a few graphs.
I frequently have to tweak the output from Graphviz and Gephi; they give me a good starting point though.

Annotate DOT graphs with images

I'm using PyDot to generate Graphviz/dot graphs in python. I would like to annotate my nodes and edges with images read from files, I've found in the documentation how to put an image as a node, but not how to put an image under a node or even less an edge.
http://www.graphviz.org/doc/info/attrs.html
http://www.graphviz.org/doc/info/shapes.html
http://www.graphviz.org/Documentation/html/shapehowto.html
Does anybody know how to do that?
You can use HTML in the labels for nodes and edges. You can find details here: http://www.graphviz.org/doc/info/shapes.html#html
Basically you can say something
"a" -> "b" [label = <<TABLE><TR><TD><IMG SRC="path/to/picture"/></TD></TR></TABLE>>]
You can add as many rows and columns as you want in the html labels. It's a little more verbose than standard text labels, but you can do a bit more with them.
One method which can work in cases where edges will always be drawn in the same position is to create a PNG with a transparent background and position the icon in the same place that your edge will be drawn, or use the labeldistance/labelangle attributes to move. I'm not familiar with PyDot but using SQL I would create a case to determine whether or not the image is displayed on the node..
Problem with this method is that the graphs which I'm working with are always positioned differently and will never be the same, so in an ideal case I'd like to add the image to the edge label, or under/to the right of the edge label etc. Did you ever manage to find a workaround?

Resources