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. Prefer discoverable plot kwargs: labels, label_position, color_by, exposure, show_removed_edges (legacy aliases still work).
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, labels=["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. Temporal glyphs, single-node placement, and display-only surgery are summarised in Terminology. Scope limits: BOUNDARIES.md.
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. Edges are straight by default; mark curved edges with :curved, CurvedEdge(), or a bow fraction to receive quadratic Bézier samples (long_edge_routing = :quadratic) (Output Quality). 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. Node labels prefer labels=; default label_position = :outer (compact markers, external auto-aligned text). Use :inner with fit_node_size_to_labels=true for in-node white labels. Optional color_by role colouring; on time-indexed plots, roles propagate across variable rows (see Skeletons & Time). 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
Package overview
- Getting Started
- Basic Plotting
- Node Types & Styling
- Visual grammar: interactions and DiD SWIGs
- Skeletons and time-indexed plots
- Bidirected Edges
- Causal highlighting
- Interventions (
do(·)) - API Reference
- Layout utilities
- Main Plotting Functions
- Convenience Pattern Functions
- Types
- Graph Construction
- Highlighting
- Interventions
- Visual grammar (interactions / DiD)
- Smart / dagitty colouring
- Preferred keyword names
- Label Alignment
- Layout Utilities
- Edge routing
- Themes and Styling
- Node Type Styling
- Mixed Graph Operations
- Utilities