| plot.caugi | R Documentation |
Creates a grid graphics object (gTree) representing a caugi graph.
If the graph has not been built yet, it will be built automatically before
plotting. This implementation uses idiomatic grid graphics with viewports
for proper coordinate handling.
## S3 method for class 'caugi'
plot(x, layout = "auto", node_style = list(),
edge_style = list(), label_style = list(), tier_style = list(),
main = NULL, title_style = list(), asp = NA,
outer_margin = grid::unit(2, "mm"), title_gap = grid::unit(1, "lines"), ...)
x |
A |
layout |
Specifies the graph layout method. Can be:
|
node_style |
List of node styling parameters. Supports:
|
edge_style |
List of edge styling parameters. Can specify global options
or per-type options via
|
label_style |
List of label styling parameters. Supports:
|
tier_style |
List of tier box styling parameters. Tier boxes are shown
when
|
main |
Optional character string for plot title. If |
title_style |
List of title styling parameters. Supports:
|
asp |
Numeric value for the y/x aspect ratio. If |
outer_margin |
Grid unit specifying outer margin around the plot.
Default is |
title_gap |
Grid unit specifying gap between title and graph.
Default is |
... |
Additional arguments passed to |
A caugi_plot object that wraps a gTree for grid graphics
display. The plot is automatically drawn when printed or explicitly
plotted.
Other plotting:
add-caugi_plot-caugi_plot,
caugi_layout(),
caugi_layout_bipartite(),
caugi_layout_circle(),
caugi_layout_fruchterman_reingold(),
caugi_layout_kamada_kawai(),
caugi_layout_sugiyama(),
caugi_layout_tiered(),
caugi_plot(),
divide-caugi_plot-caugi_plot
cg <- caugi(
A %-->% B + C,
B %-->% D,
C %-->% D,
class = "DAG"
)
plot(cg)
# Use a specific layout method (as string)
plot(cg, layout = "kamada-kawai")
# Use a layout function
plot(cg, layout = caugi_layout_sugiyama)
# Pre-compute layout and use it
coords <- caugi_layout_fruchterman_reingold(cg)
plot(cg, layout = coords)
# Bipartite layout with a function
cg_bp <- caugi(A %-->% X, B %-->% X, C %-->% Y)
partition <- c(TRUE, TRUE, TRUE, FALSE, FALSE)
plot(cg_bp, layout = caugi_layout_bipartite, partition = partition)
# Customize nodes
plot(cg, node_style = list(fill = "lightgreen", padding = 0.8))
# Customize edges by type
plot(
cg,
edge_style = list(
directed = list(col = "blue", arrow_size = 4),
undirected = list(col = "red")
)
)
# Add a title
plot(cg, main = "Causal Graph")
# Customize title
plot(
cg,
main = "My Graph",
title_style = list(fontsize = 18, col = "blue", fontface = "italic")
)
# Respect aspect ratio (1:1)
plot(cg, asp = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.