graphviz.chart: Plotting networks with probability bars

View source: R/frontend-plot.R

graphviz.chartR Documentation

Plotting networks with probability bars


Plot a Bayesian network as a graph whose nodes are barplots representing the marginal distributions of the corresponding variables. Requires the Rgraphviz and gRain packages.


graphviz.chart(x, type = "barchart", layout = "dot", draw.labels = TRUE,
  grid = FALSE, scale = c(0.75, 1.1), col = "black", bg = "transparent",
  text.col = "black", bar.col = "black", = bg, main = NULL,
  sub = NULL)



an object of class


a character string, the type of graph used to plot the probability distributions in the nodes. Possible values are barchart, dotplot and barprob (a barchart with parameter values printed over the bars).


a character string, the layout argument that will be passed to Rgraphviz. Possible values are dots, neato, twopi, circo and fdp. See Rgraphviz documentation for details.


a boolean value, whether to print the labels of the parameters of each variable.


a boolean value, whether to draw to a reference grid for the probability distributions. If grid is TRUE, a vertical grid is drawn at probabilities c(0, 0.25, 0.50, 0.75) for discrete nodes, and at the quartiles of the regression coefficients range for continuous nodes. If grid is a numeric vector, a verical grid is drawn at the specified values. If grid is a named list, each element is a set of grid points can be specificed for the corresponding node.


a vector of two positive numbers, used by Rgraphviz to determine the size and the aspect ratio of the nodes.

col, bg, text.col, bar.col,

the colours of the node border, of the barchart background, of the text, of the bars and of the strip background.


a character string, the main title of the graph. It's plotted at the top of the graph.


a character string, a subtitle which is plotted at the bottom of the graph.


graphviz.chart() invisibly returns NULL.


Marco Scutari


## Not run: 
modelstring = paste("[HIST|LVF][CVP|LVV][PCWP|LVV][HYP][LVV|HYP:LVF][LVF]",
dag = model2network(modelstring)
fitted =, alarm)

# Netica style.
graphviz.chart(fitted, grid = TRUE, bg = "beige", bar.col = "black")
# Hugin style.
graphviz.chart(fitted, type = "barprob", grid = TRUE, bar.col = "green", = "lightyellow")
# GeNIe style.
graphviz.chart(fitted, col = "darkblue", bg = "azure", bar.col = "darkblue")
# personal favourites.
graphviz.chart(fitted, type = "barprob", grid = TRUE, bar.col = "darkgreen", = "lightskyblue")
graphviz.chart(fitted, type = "barprob", grid = TRUE, bar.col = "gold", = "lightskyblue")
# dot-plot version.
graphviz.chart(fitted, type = "dotplot")

## End(Not run)

bnlearn documentation built on May 29, 2024, 5:07 a.m.