DAGMakie.jl
DAGMakie.DAGMakie — Module
DAGMakiePlot directed acyclic and related causal graphs with Makie, building on GraphMakie.jl. Defaults omit axes and grids; helpers cover common causal diagram conventions, bidirected confounding, and display-only do(·) surgery.
Identification (d-separation, adjustment sets) belongs in CausalInference.jl; executable SCMs belong in CausalDynamics.jl. Optional convenience plots that call CausalInference activate via using CausalInference.
Layouts are deterministic for DAGs; themes (dag_theme, …) control stroke and spacing. Pattern constructors include chain, fork, collider, and confounding.
Quick Start
using Graphs, DAGMakie, CairoMakie
g = SimpleDiGraph(3)
add_edge!(g, 1, 2) # Z → X
add_edge!(g, 1, 3) # Z → Y
add_edge!(g, 2, 3) # X → Y
fig, ax, p = dagplot(g, nlabels=["Z", "X", "Y"])
save("confounding_dag.png", fig)Main Functions
dagplot(g; kwargs...)- Create a new figure with DAG plotdagplot!(ax, g; kwargs...)- Plot DAG into existing axiscompute_auto_label_aligns(g, positions)- Compute optimal label positionsdag_theme()- Return the default Makie theme for DAG figures
Convenience Patterns
dagplot_chain(labels)- X₁ → X₂ → ... → Xₙdagplot_fork(labels)- X ← Y → Zdagplot_collider(labels)- X → Y ← Zdagplot_confounding(labels)- Z → X → Y, Z → Ydagplot_mediation(labels)- X → M → Y, X → Y
See the documentation for full details and examples.
DAGMakie plots directed acyclic, directed cyclic, and mixed causal graphs with Makie, building on GraphMakie.jl. Defaults omit axes and grids; node types follow common causal-diagram conventions (observed, latent, treatment, outcome), with helpers for bidirected confounding, path highlighting, display-only do(·) surgery, and a visual grammar for interaction IDAGs and DiD SWIGs.
Compared with R and Python
| Need | DAGMakie | Familiar elsewhere |
|---|---|---|
| Layered causal DAG + bidirected arcs | Yes | ggdag, dagitty |
| Path / adjustment highlighting | Yes | ggdag + dagitty |
| Time-indexed / SWIG / DiD visual grammar | Unique | Custom plots |
| Same Makie stack as SciML figures | Unique | — |
Choose DAGMakie for publication figures in the Julia/Makie stack. Prefer ggdag / dagitty for tidyverse pipelines or the dagitty GUI. Details: Comparison · ECOSYSTEM_COMPARISON.md.
Capabilities
Layouts are deterministic for DAGs (layered) and SCC-aware for cyclic graphs. Undirected skeletons and time-indexed grids cover CPDAG output and unrolled temporal DAGs (Skeletons & Time). Themes (default, minimal, bold, presentation) control stroke weight and spacing. Convenience constructors cover chain, fork, collider, confounding, and mediation patterns. Edge labels (elabels, structural_edge_labels) carry structural path coefficients or short LaTeX mechanism fragments (Getting started). Path helpers accept adjustment sets directly, or load CausalInference / CausalDynamics when identification should be computed at plot time.
Installation
using Pkg
Pkg.add("DAGMakie")DAGMakie is on the Julia General registry. It is visualisation-only; identification and do(·) calculus stay in CausalInference.jl or CausalDynamics.jl.
Or for development:
Pkg.develop(url="https://github.com/SimonAB/DAGMakie.jl")Quick example
using DAGMakie, CairoMakie
# Confounding DAG Z → X → Y, Z → Y (triangle layout: confounder on top)
fig, ax, p = dagplot_confounding(["Z", "X", "Y"])
fig