Is it possible to write vertically in a node/HTML-like label? (Rotating the text by 90, 180 and 270 degrees) If yes, how?
Unfortunately, Graphviz does not directly support rotated text. However you can create external image files with rotated text (I used ImageMagick) and include them in your HTNL-like nodes.
Creating the images:
convert -background lightblue -fill blue -pointsize 72 label:'No\nParking' im.png;
convert -rotate 90 im.png im90.png; convert -rotate 180 im.png im180.png
Graphviz source:
graph i{
t [shape=plaintext,label=<
<TABLE CELLSPACING="2" CELLPADDING="2" BORDER="1">
<TR>
<TD><IMG SRC="image_dir/im.png" /></TD>
<TD><IMG SRC="image_dir/im90.png" /></TD>
<TD><IMG SRC="image_dir/im180.png" /></TD>
</TR>
</TABLE>
>
]
}
Produces:
Related
Is it possible to have graphviz/dot render a node as a circle that is split in the middle horizontally, with a top and bottom text content? Something like a record, but the final shape should be a circle. Currently I'm using Mrecord, but that's only a rounded rectangle, not a circle shape.
I searched for ways to increase the border radius of Mrecord (to make it a quasi-circle) but that did not work. I also tried Mcircle, which is not what I was looking for.
Not directly, but you can create a circle-shaped node, divided in half with the wedged attribute and in the HTML-like label write a HTML <TABLE> without borders which will place text on top of the node.
Script:
digraph {
nodepie [shape = "circle"
style = "wedged"
fillcolor="white;0.5:white"
label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0">
<TR>
<TD>one</TD>
</TR>
<TR>
<TD>two</TD>
</TR>
</TABLE>>];
}
Result:
Not directly, but you can create an image (svg, png, ...) that looks exactly like you want, using any drawing program, & then include that image in your Graphviz graph.
I am wanting to change the background color of an edge label in Graphviz. At the moment the only way I can see of doing this is using an HTML table.
Eg,
edge [len=3,fontcolor=red];
DeviceA -- DeviceB [headlabel=<
<table border="0" cellborder="0">
<tr>
<td bgcolor="white">Head Label</td>
</tr>
</table>>
,taillabel="Tail Label"];
What I would like to be able to do is something shorter/cleaner:
edge [len=3,fontcolor=red,bgcolour=white];
DeviceA -- DeviceB [headlabel="Head Label",taillabel="Tail Label"];
Is their an option for this in graphviz?
The reason I am trying to do this is because end labels end up written over edges, which makes the label difficult to read, a background color the same color as the canvas, artificially creates a break in the edge.
Thanks
In GraphViz there is no way to change the Background Colour of an Edge Label. However you can achieve the same by using a HTML Table:
Eg:
edge [len=3,fontcolor=red];
DeviceA -- DeviceB [headlabel=<
<table border="0" cellborder="0">
<tr>
<td bgcolor="white">Head Label</td>
</tr>
</table>>
,taillabel="Tail Label"];
I have a client that is nit picking the position of a trademark symbol and doesnt want to use the sup because it is too high.
So i have this
<table>
<tr>
<td class="mobilePadding mobileFontFix" bgcolor="#ffffff" style="background:#fff;padding:40px 20px 10px 40px;color: #636363;line-height: 22px;font-size: 24px;">
Some Test Before <span style="font-size: 14px;position: relative;bottom: 4px;">™</span> some Text after
</td>
</tr>
</table>
But of course Outlook doesn't support position:relative
Any other thoughts on how i can move the trademark up slightly in a way that outlook will render it?
Two suggestions I would have would be:
Use the <sup> tag, but add a <span> around the outside, with the <span> containing style="font-size:Xpx; line-height:Xpx;" , ensuring that "X" for the line-height and font-size are smaller than the rest of the of your styled text, this will bring it down lower in terms of height.
Replace the TM symbol with an image of the symbol, this may give you more flexibility with it's position by using padding or spacers.
I want to assign multiple color to a node in graphViz. the optimal solution would be a circular node with a pie chart format.
I know one way which is to use HTML tag. the following is a simple example:
graph G{
1--2;
1[shape=none,margin=0,label=<
<table BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<tr>
<td bgcolor="red"></td>
<td bgcolor="blue"></td>
</tr>
</table> >];
2[shape=circle,style=filled,fillcolor=yellow];
3[shape=circle,style=filled,fillcolor=yellow];
}
However, there are some problems:
the node 1 has no label (I want it to have label "1" )
the edge connecting the node 1 to node 2 is not completely attached to node 1. In other words, there is a space between node 1 and the edge connecting it to node 2.
node 1 is rectangular. how can I have a circular node?
If there is no way to overcome these problems, would you please suggest any other graph visualization software?
You can achieve this by
graph G{
1--2;
1[shape=circle,style=wedged,fillcolor="red:blue"];
2[shape=circle,style=filled,fillcolor=yellow];
3[shape=circle,style=filled,fillcolor=yellow];
}
The advantage of the approach is that you can use more than 2 colors in a node.
For your 1st problem, it really depends on your implementation for the two-color nodes. You have multiple solutions described in this post: Two colours in one node with graphviz's dot? With your current code, the easiest way to add a label is to write it inside ot the <td></td> tags, like in the following code:
graph G{
1--2;
1[shape=none,margin=0,label=<
<table BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<tr>
<td bgcolor="red">1</td>
<td bgcolor="blue"></td>
</tr>
</table> >];
2[shape=circle,style=filled,fillcolor=yellow];
3[shape=circle,style=filled,fillcolor=yellow];
}
However, it won't be centered, and I think a gradient node is preferrable.
For your second problem, you need to declare a port on the cells of your array, and use them to anchor your edges when drawing edges:
graph G{
1[shape=none, label=<
<table MARGIN="0" BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<tr>
<td bgcolor="red" port="L">1</td>
<td bgcolor="blue" port="R"></td>
</tr>
</table> >];
2[shape=circle,style=filled,fillcolor=yellow];
3[shape=circle,style=filled,fillcolor=yellow];
1:L--2;
}
For your 3rd problem, according to http://www.graphviz.org/doc/info/shapes.html, you have the possibility to create custom shapes. I don't know any way to create such rounded arrays, so you should look in this direction I think.
I've created a graphviz table node:
<TR>
<TD COLSPAN="3" BGCOLOR="lightgrey">LineOne LineTwo</TD>
</TR>
I'd like to have Line1, Line2 in separate lines. I've tried <br>, \n and , without luck - some just appear as is in the rendered image, and some cause errors.
It's a self-closing tag nitpick:
<TD COLSPAN="3" BGCOLOR="lightgrey">LineOne<br/>LineTwo</TD>
^