if (FALSE) {
model <- make_model('X -> K -> Y')
# Simple plot
model |> plot_model()
# Adding additional layers
model |> plot_model() +
ggplot2::coord_flip()
# Adding labels
model |>
plot_model(
labels = c("A long name for a \n node", "This", "That"),
nodecol = "white",
textcol = "black")
# Math labels: add parse = TRUE
make_model() |>
plot_model(
labels = c("alpha^2", "beta[1]"),
parse = TRUE,
textcol = "black", nodecol = "white")
# Mixed math text labels: add parse = TRUE
make_model() |>
plot_model(
labels = c('alpha ~ "class"', 'beta ~ "class"'),
parse = TRUE,
textcol = "black", nodecol = "white",)
# Adding math title after graph creation
make_model() |>
plot_model() +
ggplot2::labs(title = expression(paste(Gamma, " graph")))
}
# DAG with unobserved confounding and shapes and position control
make_model('Z -> X -> Y; X <-> Y') |>
plot(x_coord = 1:3, y_coord = 1:3, shape = c(15, 16, 16))
# Sometimes clipping of nodes or labels arises and can be dealt with thus:
make_model() |>
plot_model() +
ggplot2::coord_cartesian(clip = "off")
Run the code above in your browser using DataLab