Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

CLI

By default, draw_tree generates TikZ code and prints it to standard output. There are also options to generate a complete LaTeX document, an SVG, PDF or a PNG directly, either by specifying the desired format or by using the output filename extension:

draw_tree games/example.ef --pdf

CLI Options

CategoryOptionDescription
Formatting--pdf, --png, --svg, --texOutput format instead of printing TikZ code.
--output=mygame.pdfSpecify output filename (extension determines format).
--dpi=XSet PNG resolution in DPI (72-2400, default: 300).
Layoutscale=X.XSet scale factor (0.01 to 100).
--horizontalSwitch from vertical to horizontal layout (left-to-right).
--mirrorMirror the tree left-to-right (flip xshift values).
--legend-position=XCorner for the colour legend: top-left (default), top-right, bottom-left, bottom-right.
--action-label-dist=X.XDistance of action labels from the edge (default: 1.0).
--action-label-position=X.XPosition of action labels along the edge (0.0 to 1.0, default: 0.5).
--level-scaling=X.XLevel spacing multiplier (for .efg files, default: 1.0).
--sublevel-scaling=X.XSublevel spacing multiplier (for .efg files, default: 1.0).
--width-scaling=X.XWidth spacing multiplier (for .efg files, default: 1.0).
--shared-terminal-depthEnforce shared terminal node depth (for .efg files).
Information Sets--iset-fillFill information sets with player colors.
--iset-fill-opacity=X.XOpacity of information set fill (0.0-1.0, default: 0.2).
--iset-boundary=XBoundary style: solid, dotted, none (default: solid).
Aesthetics--color-scheme=XSet color scheme (default, gambit, distinctipy, colorblind, custom).
--edge-thickness=X.XSet thickness of edges (default: 1.0).
--font=[serif|sans-serif|monospace]Set the global LaTeX font family.
--font-size=[small|normalsize|large|Large]Set the LaTeX font size command.
--bold, --italicUse bold or italic text for labels and payoffs.
--custom-colors="0:#HEX,..."Map player indices (0=chance) to hex colors.
--node-size=X.XSize of player nodes in mm (default: 1.5).
gridShow helper grid in the background.
Conversion--to-efgConvert .ef file to Gambit .efg format (no rendering).
--to-efConvert .efg file to .ef format (requires pygambit, no rendering).

Format Conversion

The CLI also supports converting between .ef and .efg formats without rendering:

# Convert EF to Gambit EFG
draw_tree games/example.ef --to-efg

# Convert EFG to EF
draw_tree games/efg/example.efg --to-ef

# Specify output filename
draw_tree games/example.ef --to-efg --output=my_game.efg

Normal Form Games (NFG)

.nfg files are supported directly. The default output (no format flag) prints the raw \begin{game}...\end{game} LaTeX body; PDF/PNG/SVG compilation requires pdflatex and the sgame package (texlive-games).

# Print \begin{game}...\end{game} body to stdout
draw_tree games/nfg/example.nfg

# Compile payoff table to PDF
draw_tree games/nfg/example.nfg --pdf

# Compile payoff table to PNG
draw_tree games/nfg/example.nfg --png

# Compile payoff table to SVG with custom output name
draw_tree games/nfg/example.nfg --svg --output=battle_of_sexes.svg