-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Padding of custom nodes #410
Comments
Try using For example: from diagrams import Diagram, Edge, Node
common_node_attr = {
"fixedsize": "true", # true | false
"imagescale": "true", # true | false | width | height | both
"labelloc":"b", # t | c | b
"penwidth": "0",
"width": "2",
"height": "2",
}
with Diagram("\n\nNode Sizing", direction="TB", show=False) as diag:
N1 = Node("N2", image="icon1.png", **common_node_attr)
N2 = Node("N1", image="icon2.png", **common_node_attr)
N1 >> Edge() >> N2
diag For |
You can also use an HTML Node, then adjust the For more info on "HTML-Like Labels" see: https://graphviz.gitlab.io/doc/info/shapes.html#html Example code and output below. from diagrams import Diagram, Node, Edge
graph_attr = {
"splines":"spline",
}
html_img_node_base = """<
<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0">
<TR><TD fixedsize="true" width="100" height="100"><IMG SRC="{0}" /></TD></TR>
<TR><TD>{1}</TD></TR>
</TABLE>
>"""
img1 = "etcd.png"
label1 = "etcd"
img2 = "pod_w_docker.png"
label2 = "pod_w_docker"
html_node_1 = html_img_node_base.format(img1, label1)
html_node_2 = html_img_node_base.format(img2, label2)
with Diagram("\n\nHTML Node Option", direction="TB", show=False) as diag:
etcd = Node(shape="plaintext", label=html_node_1, width="1.0", height="1.5",)
pod = Node(shape="plaintext", label=html_node_2, width="1.0", height="1.5",)
etcd >> Edge() >> pod
diag Also see these issue comments: |
I've created some custom nodes with png icons. When I render the graph with
direction="TB"
I get a lot of padding above the icons. Withdirection="LR"
it also shows up by giving linking arrows a position which is above the icon. My icons have dimension [208 x 208].Is there a way of reducing this white-space padding?
Left to right:
Top to bottom:
The text was updated successfully, but these errors were encountered: