plot_model: Plots a DAG in ggplot style using a causal model input

View source: R/plot_dag.R

plot_modelR Documentation

Plots a DAG in ggplot style using a causal model input

Description

If confounds are indicated (provided in attr(model$P, 'confounds')), then these are represented as bidirectional arcs. Builds on functionality from ggdag and dagitty.

Usage

plot_model(
  model = NULL,
  x_coord = NULL,
  y_coord = NULL,
  title = "",
  textcol = "white",
  textsize = 3.88,
  shape = 16,
  nodecol = "black",
  nodesize = 16
)

Arguments

model

A causal_model object generated from make_model

x_coord

A vector of x coordinates for DAG nodes. If left empty, coordinates are randomly generated

y_coord

A vector of y coordinates for DAG nodes. If left empty, coordinates are randomly generated

title

String specifying title of graph

textcol

String specifying color of text labels

textsize

Numeric, size of text labels

shape

Indicates shape of node. Defaults to circular node.

nodecol

String indicating color of node that is accepted by ggplot's default palette

nodesize

Size of node.

Value

A DAG plot in ggplot style.

Examples


## Not run: 
model <- make_model('X -> K -> Y; X <-> Y')

model |>
  CausalQueries:::plot_model()
model |>
  CausalQueries:::plot_model(
    x_coord = 1:3,
    y_coord = 1:3,
    title = "Mixed text and math: $\\alpha^2 + \\Gamma$")

## End(Not run)


CausalQueries documentation built on June 22, 2024, 6:50 p.m.