node_aes: Insert node aesthetic attributes during node creation

Description Usage Arguments Examples

View source: R/node_aes.R

Description

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.

Usage

1
2
3
4
5
6
7
node_aes(shape = NULL, style = NULL, penwidth = NULL, color = NULL,
  fillcolor = 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)

Arguments

shape

the shape to use for the node. Some possible shape types include: circle, rectangle, triangle, plaintext, square, and polygon.

style

the node line style. The style types that can be used are filled, invisible, diagonals, rounded, dashed, dotted, solid, and bold.

penwidth

the thickness of the stroke line (in pt units) for the node shape. The default value is 1.0.

color

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.

fillcolor

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.

fontname

the name of the system font that will be used for any node text.

fontsize

the point size of the font used for any node text.

fontcolor

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.

peripheries

the repeated number of node shapes (of increasing size) to draw at the node perhipery.

height

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.

width

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.

x

the fixed position of the node in the x direction. Any integer-based or floating point value will be accepted.

y

the fixed position of the node in the y direction. Any integer-based or floating point value will be accepted.

group

the node group.

tooltip

text for a node tooltip.

xlabel

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.

URL

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.

sides

when using the shape polygon, this value will provide the number of sides for that polygon.

orientation

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.

skew

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.

distortion

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.

gradientangle

the path angle for the node color fill gradient.

fixedsize

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).

labelloc

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.

margin

sets the amount of space around the node's label. By default, the value is 0.11,0.055.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# 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()

DiagrammeR documentation built on March 18, 2018, 1:25 p.m.