plot.HydeNetwork: Plotting Utilities for Probabilistic Graphical Network

Description Usage Arguments Details Author(s) Source Examples

View source: R/plot.HydeNetwork.R

Description

Generate and customize plots of a HydeNetwork class network. HydeNet provides some initial defaults for standard variable nodes, deterministic nodes, decision nodes, and utility nodes. Since these nodes are assumed to be of inherent difference and interest, the options are defined in a way to make these easier to identify in a plot. The default options may be altered by the user to their liking by invoking HydePlotOptions. Node attributes are more fully explained in the documentation for the DiagrammeR package. Individual nodes may be define with customNode.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## S3 method for class 'HydeNetwork'
plot(
  x,
  customNodes = NULL,
  customEdges = NULL,
  ...,
  removeDeterm = FALSE,
  useHydeDefaults = TRUE
)

mergeCustomNodes(node_df, customNodes)

mapEdges(n, p, node_df)

mergeCustomEdges(edge_df, customEdges)

customNode(node_id, ...)

HydePlotOptions(
  variable = NULL,
  determ = NULL,
  decision = NULL,
  utility = NULL,
  restorePackageDefaults = FALSE
)

Arguments

x

an object of class HydeNetwork

customNodes

a data frame giving additional specifications for nodes. The customizations provided here will override the default settings.

customEdges

a data frame giving custom settings for edges (arrows) between nodes.

...

for the plot method, additional arguments to be passed to DiagrammeR::render_graph. For customNode, named node attributes to assign to a node's plotting characteristics.

removeDeterm

A logical value. When FALSE (the default), it has no effect. When TRUE, deterministic nodes are removed from the network and a reduced plot with no deterministic nodes is rendered.

useHydeDefaults

A logical value indicating if the default plot parameters in options("Hyde_plotOptions") should be applied to the plot.

node_df

A data frame of node attributes

n

node names from a network object

p

the list of parents from a network object

edge_df

The default edge attribute data frame

node_id

The name of a node in a HydeNetwork object. May be quoted or unquoted.

variable, determ, decision, utility

Named lists of attributes to use as defaults node attribute settings for each variable type.

restorePackageDefaults

A logical value. When TRUE, the original package defaults are restored.

Details

GraphViz is an enormous set of resources for customizing and we cannot adequately describe them all here. See 'Sources' for links to additional documentation from the DiagrammeR package and the GraphViz website.

With its default settings, HydeNet makes use of five node attributes for plotting networks. These are

HydeNet assumes the GraphViz defaults for edge nodes (arrows).

See the Plotting Hyde Networks vignette (vignette("HydeNetPlots")) for a more thorough explanation of plotting networks.

Author(s)

Jarrod Dalton and Benjamin Nutter

Source

http://rich-iannone.github.io/DiagrammeR/graphviz_and_mermaid.html
See especially the section on Attributes

http://graphviz.org/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## Not run: 
#* Plots may open in a browser.
data(BlackJack, package="HydeNet")
plot(BlackJack)

HydePlotOptions(variable=list(shape = "rect", fillcolor = "#A6DBA0"),
                determ = list(shape = "rect", fillcolor = "#E7D4E8",
                              fontcolor = "#1B7837", linecolor = "#1B7837"),
                decision = list(shape = "triangle", fillcolor = "#1B7837",
                                linecolor = "white"),
                utility = list(shape = "circle", fillcolor = "#762A83", 
                               fontcolor = "white"))
plot(BlackJack)

HydePlotOptions(restorePackageDefaults = TRUE)

plot(BlackJack,
     customNodes = customNode(payoff, 
                              fillcolor = "purple", shape = "circle", 
                              fontcolor = "white", height = "2",
                              style="filled"))
plot(BlackJack,
  customNodes = 
    dplyr::bind_rows(
      customNode(pointsAfterCard3,
                 shape = "circle",
                 style = "radial",
                 fillcolor = "#1B7837:#762A83",
                 fontcolor = "black",
                 height = "2"),
      customNode(playerFinalPoints,
                 shape = "circle",
                 style = "wedged",
                 height = "3",
                 fillcolor = c("red:orange:yellow:green:blue:purple"))))

## End(Not run)

Example output

Loading required package: nnet
Warning message:
In file(con, "rb") : cannot open file '/etc/timezone': Permission denied
Warning message:
In file(con, "rb") : cannot open file '/etc/timezone': Permission denied
Warning message:
In file(con, "rb") : cannot open file '/etc/timezone': Permission denied
Warning message:
In file(con, "rb") : cannot open file '/etc/timezone': Permission denied

HydeNet documentation built on July 8, 2020, 5:15 p.m.