This helper function should be invoked to provide values for the namesake
node_aes
argument, which is present in any function where nodes are
created.
node_aes(
shape = NULL,
style = NULL,
penwidth = NULL,
color = NULL,
fillcolor = NULL,
image = NULL,
fontname = NULL,
fontsize = NULL,
fontcolor = NULL,
peripheries = NULL,
height = NULL,
width = NULL,
x = NULL,
y = NULL,
group = NULL,
tooltip = NULL,
xlabel = NULL,
URL = NULL,
sides = NULL,
orientation = NULL,
skew = NULL,
distortion = NULL,
gradientangle = NULL,
fixedsize = NULL,
labelloc = NULL,
margin = NULL
)
The shape to use for the node. Some possible shape
types
include: circle
, rectangle
, triangle
, plaintext
, square
, and
polygon
.
The node line style. The style
types that can be used are:
filled
, invisible
, diagonals
, rounded
, dashed
, dotted
, solid
,
and bold
.
The thickness of the stroke line (in pt units) for the node
shape. The default value is 1.0
.
The color of the node's outline. Can be any of the named colors
that R knows about (obtained using the colors()
function), or, a
hexadecimal color code.
The color with which to fill the shape of the node. Can be
any of the named colors that R knows about (obtained using the colors()
function), or, a hexadecimal color code.
A reference to an image location.
The name of the system font that will be used for any node text.
The point size of the font used for any node text.
The color used for any node text. Can be any of the named
colors that R knows about (obtained using the colors()
function), or, a
hexadecimal color code.
The repeated number of node shapes (of increasing size) to draw at the node periphery.
The height of the node shape, in inches. The default value is
0.5
whereas the minimum value is 0.02
. This is understood as the
initial, minimum height of the node. If fixedsize
is set to TRUE
, this
will be the final height of the node. Otherwise, if the node label requires
more height to fit, the node's height will be increased to contain the
label.
The width of the node shape, in inches. The default value is
0.5
whereas the minimum value is 0.02
. This is understood as the
initial, minimum width of the node. If fixedsize
is set to TRUE
, this
will be the final width of the node. Otherwise, if the node label requires
more width to fit, the node's width will be increased to contain the label.
The fixed position of the node in the x direction. Any integer-based or floating point value will be accepted.
The fixed position of the node in the y direction. Any integer-based or floating point value will be accepted.
The node group.
Text for a node tooltip.
External label for a node. The label will be placed outside of the node but near it. These labels are added after all nodes and edges have been placed. The labels will be placed so that they do not overlap any node or label. This means it may not be possible to place all of them.
A URL to associate with a node. Upon rendering the plot, clicking nodes with any associated URLs will open the URL in the default browser.
When using the shape polygon
, this value will provide the
number of sides for that polygon.
This is the angle, in degrees, that is used to rotate
nodes that have a shape
of polygon
. Not that for any of the polygon
shapes (set by the sides
node attribute), a value for orientation
that
is 0
results in a flat base.
A 0-1
value that will result in the node shape being skewed to
the right (from bottom to top). A value in the range 0
to -1
will skew
the shape to the left.
A distortion factor that is used only when a shape
of
polygon
is used. A 0-1
value will increasingly result in the top part
of the node polygon shape to be larger than the bottom. Moving from 0
toward -1
will result in the opposite distortion effect.
The path angle for the node color fill gradient.
If set to FALSE
, the size of a node is determined by
smallest width and height needed to contain its label, if any, with a
margin specified by the margin
node attribute. The width and height must
also be at least as large as the sizes specified by the width
and
height
node attributes, which specify the minimum values. If set to
TRUE
, the node size is entirely specified by the values of the width
and height
node attributes (i.e., the node is not expanded in size to
contain the text label).
Sets the vertical placement of labels for nodes and clusters.
This attribute is used only when the height of the node is larger than the
height of its label. The labelloc
node attribute can be set to either t
(top), c
(center), or b
(bottom). By default, the label is vertically
centered.
Sets the amount of space around the node's label. By default,
the value is 0.11,0.055
.
Other Aesthetics:
edge_aes()
,
node_edge_aes_data
# Create a new graph and add
# a path with several node
# aesthetic attributes
graph <-
create_graph() %>%
add_path(
n = 3,
type = "path",
node_aes = node_aes(
shape = "circle",
x = c(1, 3, 2),
y = c(4, -1, 3)
)
)
# View the graph's internal
# node data frame; the node
# aesthetic attributes have
# been inserted
graph %>% get_node_df()
# Create a new graph which is
# fully connected
graph <-
create_graph() %>%
add_full_graph(
n = 4,
node_data = node_data(value = 1:4),
node_aes = node_aes(
x = c(2, 1, 3, 2),
y = c(3, 2, 2, 1)
),
edge_aes = edge_aes(color = "blue")
)
Run the code above in your browser using DataLab