DAGMakie.jl

DAGMakie.DAGMakieModule
DAGMakie

Plot 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 plot
  • dagplot!(ax, g; kwargs...) - Plot DAG into existing axis
  • compute_auto_label_aligns(g, positions) - Compute optimal label positions
  • dag_theme() - Return the default Makie theme for DAG figures

Convenience Patterns

  • dagplot_chain(labels) - X₁ → X₂ → ... → Xₙ
  • dagplot_fork(labels) - X ← Y → Z
  • dagplot_collider(labels) - X → Y ← Z
  • dagplot_confounding(labels) - Z → X → Y, Z → Y
  • dagplot_mediation(labels) - X → M → Y, X → Y

See the documentation for full details and examples.

source

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

NeedDAGMakieFamiliar elsewhere
Layered causal DAG + bidirected arcsYesggdag, dagitty
Path / adjustment highlightingYesggdag + dagitty
Time-indexed / SWIG / DiD visual grammarUniqueCustom plots
Same Makie stack as SciML figuresUnique

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
Example block output

Package overview