Plotting
Index
Methods
EnhancedBayesianNetworks.gplot Function
gplot(net; node_scale, label_size, title, title_scale, figsize, legend, legend_fontsize, 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.
figsize is the canvas size in centimetres, a (width, height) tuple of numbers (default (20, 20)). label_size is the node-label font size in points. Pass legend=true to draw the shape/colour key: its top-left corner sits at (legend_x, legend_y) centimetres from the top-left of the canvas, and legend_fontsize (in points) sets its text size — the icons and spacing scale with it. Returns a Compose.Context, which saveplot writes to SVG.
Examples
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;
node_scale = 1.0, # scale every node shape
label_size = 8, # node-label font size, in points
title = "", # title text above the graph
title_scale = 1.0, # title font scale
figsize = (20, 20), # canvas (width, height), in cm
legend = false, # draw the shape/colour key
legend_fontsize = 9, # legend text size in points; icons scale with it
legend_x = 13.0, # legend top-left corner x, in cm from the left
legend_y = 12.0, # legend top-left corner y, in cm from the top
background_color = "transparent", # canvas background colour
)
saveplot(p, "weather.svg")EnhancedBayesianNetworks.saveplot Function
saveplot(p, filename::String)Save a gplot result to an SVG file.
source