position - 使用 graphviz 将节点定位到子图的右侧
问题描述
我graphviz
用来绘制一个简单的潜在变量模型的 DAG:
digraph G {
splines=line;
subgraph cluster {
node [style=filled, shape=circle];
edge [color=blue]
z[fillcolor=white, color=black, pos = "0,0!"]
z -> x;
}
theta[label = "θ", shape=circle, pos = "10,0!"]
edge [color=black, style="dashed"]
theta->z
theta->x
}
输出很不错:
但我希望 θ 与 z 高度相同。那可能吗?我尝试使用该pos
属性,但如您所见,它被很好地忽略了。我在HackMD工作。
解决方案
您可以将约束=false
属性添加到theta
边缘,这样它们就不会影响布局并且节点将并排保持:
digraph G {
splines=line;
subgraph cluster1 {
node [style=filled, shape=circle];
edge [color=blue]
z[fillcolor=white, color=black, pos = "0,0!"]
z -> x;
}
theta[label = "θ", shape=circle, pos = "10,0!"]
edge [color=black, style="dashed"]
theta -> z [constraint=false]
theta -> x [constraint=false] // actually this one is unnecessary, may be omited in this example
}
此外,您可以尝试边缘方向(例如更改位置 a->b、b->a),这有时有助于定位集群。
推荐阅读
- javascript - Javascript 语法 getElementById outerHTML
- python - 配置时菜单栏不会出现在 tkinter 中
- api - 如何设计一个在一小时内只接受 100K 请求的移动 API
- javascript - 即使 server.ignore 返回 false,赛普拉斯也会取消 XMLHttpRequest
- javascript - VS Code 中的可折叠注释
- rust - 如何初始化具有特定键和值类型的 HashMap?
- java - 如何正确使用 queryUsageStats
- sql - 是否可以在 EA 中构建带有子查询的条件 SQL 查询?
- php - 逐行调试php脚本
- c# - Visual Studio Code 在编辑器中不显示错误