0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

graphvizの矢印について

Last updated at Posted at 2022-12-11

矢印の先端を変えたい!!!

結論

線自体はstyle
線の先っちょはarrowhead
で変えられます!

本文

sample_graph.py
import graphviz

g = graphviz.Digraph(format='svg', filename='test')

g.node("1","a")
g.node("2","b")
g.node("3","a")

g.edge("1","2")
g.edge("2","3")

# 表示
g.view()

この場合の表示は
2022-12-11 (4).png

矢印の先端を消して線だけにしたいのに。。。。

最初に考えた解決方法

どうせstyle とかallowStyleとかで何とかなるでしょ

無理でした

sample_graph-2.py
import graphviz

g = graphviz.Digraph(format='svg', filename='test')

g.node("1","a")
g.node("2","b")
g.node("3","a")

g.edge("1","2",style="dotted")
g.edge("2","3")

# 表示
g.view()

2022-12-11 (2).png

そうじゃない!!!

解決策

arrowhead="none" で解決しました。。

sample_graph-3.py
import graphviz

g = graphviz.Digraph(format='svg', filename='test')

g.node("1","a")
g.node("2","b")
g.node("3","a")

g.edge("1","2",arrowhead="none")
g.edge("2","3")

# 表示
g.view()

2022-12-11 (3).png

a→bが線になってますね!!!

ここに載っている奴はできそうですね

逆に根元の部分を変えたいと思ったのですがarrowtailではうまくいきませんでした。。。謎!!!
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?