add_nodes.Rd
Function to add multiple nodes (and associated paths) to an existing path diagram.
add_nodes(
input,
paths = NULL,
output = F,
shape = "box",
shape.col = "white",
shape.lwd = 2,
shape.border = "black",
shape.lty = 1,
shape.pad = 0.5,
shape.x = NA,
shape.y = NA,
text.size = 1.25,
text.col = "black",
text.spacing = NULL,
path.pad = 0.025,
path.lwd = 2,
path.col = "black",
path.length = 0.1,
path.angle = 30,
path.lty = 1,
path.code = "->",
xpd = NA,
ignore_asterisk = TRUE,
add = TRUE
)
A vector of labeled character strings; see details for more information.
An optional vector of labeled character strings; see details for more information.
Logical; if TRUE
returns a list with the
x and y-axis coordinates for each node.
The default shape for nodes, either 'box',
'circle', or 'blank'; options for individual nodes can be
specified with the tag ns=
.
The default color for nodes; options
for individual nodes can be specified with the tag nc=
.
The default line width for node borders;
options for individual nodes can be specified with the
tag nw=
.
The default border color for nodes;
options for individual nodes can be specified with the
tag nb=
.
The default border line type for nodes;
options for individual nodes can be specified with the
tag nt=
.
The default space between lines of text
for nodes; options for individual nodes can be specified
with the tag np=
.
The default fixed width for nodes;
options for individual nodes can be specified with the
tag nx=
.
The default fixed height for nodes;
options for individual nodes can be specified with the
tag ny=
.
The default size for text content;
options for individual nodes can be specified with the
tag ts=
.
The default color for text content;
options for individual nodes can be specified with the
tag tc=
.
The space between multiple lines of text;
options for individual nodes can be specified with the
tag th=
.
The space between a line or arrow and a node;
options for individual nodes can be specified with the
tag lp=
.
The default line width for paths;
options for individual nodes can be specified with the
tag lw=
.
The default line color for paths;
options for individual nodes can be specified with the
tag lc=
.
The default arrowhead length for paths;
options for individual nodes can be specified with the
tag ll=
.
The default angle of arrowheads for paths;
options for individual nodes can be specified with the
tag la=
.
The default line type for paths;
options for individual nodes can be specified with the
tag lt=
.
The default arrow direction for paths;
options for individual nodes can be specified with the
tag cd=
. Directions
are specified with the symbols ->
, <-
,
<->
, or -
.
Logical; if TRUE
ignores
asterisks for dimension purposes since they are used
to indicate bold/italic font.
Logical; if TRUE
adds nodes (and
paths if specified) to an existing figure.
Each node is specified via a text string in the format:
"Text content|x=value|y=value|..."
substituting value
with the respective x and
y-axis coordinate positions for the node, and ...
referring to additional options controlling node
aesthetics.
Options are specified as a tag followed by a value; for
example, to draw a node as an ellipse, one uses the
combined tag and value: ns=circle
. Multiple
options can be specified by separating them with the
|
symbol.
Paths (lines or arrows) can be drawn between existing nodes whose string input is labeled, via the format:
"Label|coordinate|Label|coordinate|..."
where Label
is the label in the string
vector (i.e., the name attribute), and coordinate
is one of eight values: bottom
, left
,
top
, right
, bottomleft
, topleft
,
topright
, or bottomright
.
As before, additional aesthetic options can be specified
via a tag and value, with multiple cases separated by the
|
symbol. For example, the width of a path line
can be set via the tag and value: lt=2
.
# Define vector of string inputs for nodes to draw
input = c(
# [Node label] = "Text|x=value|y=value|..."
N01 = 'Node-01|x=.2|y=.33',
# Set node shape to ellipse; resize and color text
N02 = 'Node-02|x=.5|y=.66|ns=circle|ts=2|tc=blue',
# Color node and remove border
N03 = 'Node-03|x=.8|y=.33|nc=grey80|nb=NA'
)
# Define vector of string inputs to draw paths
# between labeled nodes specified in 'input'
paths = c(
# Start of path End of path Options
# Label|coordinate|Label|coordinate|...
'N01|right|N03|left',
# Connect various nodes and coordinates
'N02|right|N03|top',
'N02|bottomright|N03|topleft',
# Orange dashed thick line
'N01|top|N02|bottom|lc=orange|lt=2|lw=4',
# Blue double-headed arrow with small arrowhead
'N01|topright|N02|bottomleft|lc=blue|ll=.1|cd=<->'
)
# Create empty figure
create_base_figure()
# Add nodes and paths
add_nodes(
input, paths = paths
)