Reputation: 5646
I'm using graphviz
to plot the DAG of a simple latent variable model:
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
}
The output is decent:
but I'd like θ to be at the same height as z. Is that possible? I tried to use the pos
attribute, but as you see, it's nicely ignored. I'm working in HackMD.
Upvotes: 1
Views: 554
Reputation: 4750
You can add constraint=false
attribute to your theta
edges so they won't affect layout and nodes will remain side by side:
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
}
Also, you may experiment with edge direction (e.g. change places a->b, b->a), this sometimes helps with positioning clusters.
Upvotes: 1