The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Type: Package
Title: Create Publication-Ready Causal Diagrams
Version: 0.2.1
Description: Creates publication-ready causal diagrams using 'ggplot2'. Provides simple templates for common causal diagrams (e.g., mediating mechanisms and parallel pathways) with customizable labels, colors, fonts, and export-friendly defaults.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.2
Imports: ggforce, ggplot2, ggtext
Suggests: shiny, shinythemes
URL: https://github.com/sebastianvanbaalen/causalplot
BugReports: https://github.com/sebastianvanbaalen/causalplot/issues
NeedsCompilation: no
Packaged: 2026-03-11 06:55:23 UTC; sebastian
Author: Sebastian van Baalen ORCID iD [aut, cre, cph]
Maintainer: Sebastian van Baalen <sebastian.van-baalen@pcr.uu.se>
Repository: CRAN
Date/Publication: 2026-03-16 19:00:02 UTC

Create a causal plot

Description

Draw a simple causal diagram using ggplot2, with rounded boxes and arrows.

Usage

causal_plot(
  labels = NULL,
  type = "1111",
  fill_variables = "grey80",
  fill_mechanisms = "grey90",
  corner_radius = 0.12,
  font = "sans",
  text_size = 4,
  text_color = "black",
  wrap_width = 24,
  arrow_length = grid::unit(3, "mm"),
  arrow_linewidth = 0.6,
  box_ratio = 0.8,
  xlim = NULL,
  ylim = NULL
)

Arguments

labels

Character vector of labels. If NULL, defaults are used.

type

Character. Layout template.

fill_variables

Fill color for the first and last box (variables).

fill_mechanisms

Fill color for the in-between boxes (mechanisms).

corner_radius

Rounded corner radius. Either a grid::unit() or a numeric (interpreted as cm).

font

Font family for labels (e.g., "sans", "serif"). Default is "sans".

text_size

Numeric label size.

text_color

Label color.

wrap_width

Integer. Approximate wrap width for labels (in characters).

arrow_length

grid::unit for arrowhead size.

arrow_linewidth

Numeric line width for arrows.

box_ratio

Numeric. Passed to coord_fixed(ratio = box_ratio). Default 0.8.

xlim

Numeric vector of length 2, or NULL for auto-computed limits.

ylim

Numeric vector of length 2, or NULL for auto-computed limits.

Details

Supported templates:

Labels are wrapped to a maximum of 5 lines. If a label would wrap to more than 5 lines (given wrap_width), an error is thrown.

Value

A ggplot object.

Examples

# Simple three-box causal diagram
causal_plot(type = "111")

# With custom labels
causal_plot(
  labels = c("Education", "Income", "Health"),
  type = "111"
)

Launch the causalplot Shiny app

Description

Opens an interactive Shiny application for building causal diagrams and typology plots using the causalplot package.

Usage

run_app(...)

Arguments

...

Additional arguments passed to runApp.

Value

This function does not return a value; it launches a Shiny app.

Examples

if (interactive()) {
  run_app()
}

Create a 2x2 typology diagram

Description

Draw a 2x2 typology diagram with four labeled quadrants, double-headed axis arrows, and axis labels using ggplot2. The diagram consists of a single rounded outer box divided into four quadrants by dashed midlines, with double-headed arrows indicating the two dimensions.

Usage

typology(
  type_labels = c("Type 1", "Type 2", "Type 3", "Type 4"),
  x_axis_label = "Dimension 2",
  y_axis_label = "Dimension 1",
  x_axis_values = c("Low", "High"),
  y_axis_values = c("Low", "High"),
  fill = "grey90",
  border_color = NA,
  line_color = "grey50",
  line_linewidth = 0.5,
  corner_radius = 0.12,
  font = "sans",
  text_size = 4,
  text_color = "black",
  axis_text_size = 3.5,
  wrap_width = 20,
  arrow_length = grid::unit(2, "mm"),
  arrow_linewidth = 0.5,
  box_ratio = 0.8,
  xlim = NULL,
  ylim = NULL
)

Arguments

type_labels

Character vector of length 4. Labels for each quadrant, in order: top-left, top-right, bottom-left, bottom-right. Default: c("Type 1", "Type 2", "Type 3", "Type 4").

x_axis_label

Character. Label for the horizontal axis (top). Default: "Dimension 2".

y_axis_label

Character. Label for the vertical axis (left side). Default: "Dimension 1".

x_axis_values

Character vector of length 2. Labels for the left (low) and right (high) ends of the x-axis. Default: c("Low", "High").

y_axis_values

Character vector of length 2. Labels for the top and bottom ends of the y-axis. Default: c("Low", "High").

fill

Fill color for the outer box. Default: "grey90".

border_color

Color of the outer box border. Default: NA (no border).

line_color

Color of the dashed dividing lines. Default: "grey50".

line_linewidth

Numeric. Line width for the dashed dividing lines. Default: 0.5.

corner_radius

Rounded corner radius. Either a grid::unit() or a numeric (interpreted as cm). Default: 0.12.

font

Font family for labels (e.g., "sans", "serif"). Default: "sans".

text_size

Numeric. Text size for type labels. Default: 4.

text_color

Color for all text labels. Default: "black".

axis_text_size

Numeric. Text size for axis labels and endpoint values. Default: 3.5.

wrap_width

Integer. Approximate wrap width for type labels (in characters). Default: 20.

arrow_length

grid::unit for arrowhead size. Default: grid::unit(2, "mm").

arrow_linewidth

Numeric line width for axis arrows. Default: 0.5.

box_ratio

Numeric. Passed to coord_fixed(ratio = box_ratio). Default: 0.8.

xlim

Numeric vector of length 2, or NULL for auto-computed limits.

ylim

Numeric vector of length 2, or NULL for auto-computed limits.

Details

The type_labels vector maps to quadrants as follows:

Value

A ggplot object.

Examples

# Basic typology with defaults
typology()

# Custom labels
typology(
  type_labels = c("Foxes", "Eagles", "Mice", "Snakes"),
  x_axis_label = "Speed",
  y_axis_label = "Size",
  x_axis_values = c("Slow", "Fast"),
  y_axis_values = c("Small", "Large")
)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.