Skip to content

Plotting

Index

Methods

EnhancedBayesianNetworks.gplot Function
julia
gplot(net; node_scale, label_scale, title, title_scale, figsize, legend, legend_scale, legend_x, legend_y)

Draw a network as a layered top-down graph. Nodes are placed by depth: roots on the first row, every other node one row below its deepest parent. Shape encodes the node type — circle for continuous, rectangle for discrete, rounded hexagon for continuous functional, pointy hexagon for discrete functional — while colour encodes precise (pale) versus imprecise (bright), with functional nodes in orange. A thick border marks a continuous node carrying a discretization. Discrete nodes also show their number of states below the name. Edges attach to the exact border of each shape.

Pass legend=true to draw the shape/colour key, positioned by legend_x and legend_y as fractions of the canvas. Returns a Compose.Context, which saveplot writes to SVG.

Examples

julia
W = DiscreteNode(:W)
W[:W=>:sunny] = 0.7
W[:W=>:rainy] = 0.3
U = ContinuousNode(:U, [:W])
U[:W=>:sunny] = Normal()
U[:W=>:rainy] = Normal(2, 1)

net = EnhancedBayesianNetwork([W, U])
add_child!(net, W, U)
order!(net)

p = gplot(net; title="weather", legend=true)
saveplot(p, "weather.svg")
source
EnhancedBayesianNetworks.saveplot Function
julia
saveplot(p, filename::String)

Save a gplot result to an SVG file.

source