Plotting trees using the latex package tikz-qtree
Author dharasim
1 Star
Updated Last
5 Years Ago
Started In
August 2018


Build Status codecov.io

Plotting trees using TikzPictures.jl and the latex package tikz-qtree.


Install the latest version of this package by:

(v0.7) pkg> add https://github.com/dharasim/TikzQTrees.jl#master

TikzQTrees is build on top of TikzPictures.jl. If you can install TikzPictures, you should also be able to use TikzQTrees.


The package implements a wrapper type TikzQTree of tree data types which implement the functions

  • value(tree) that returns the value of the root of the tree, and
  • children(tree) that returns an iterator over the children of the root of the tree.

It also provides SimpleTree, an example of a type that can be wrapped into TikzQTree:

mutable struct SimpleTree{T}
    value    :: T
    children :: Vector{SimpleTree{T}}

TikzQTrees are converted into TikzPictures to show them in the Juno plot pane and IJulia notebooks. In the REPL, the tex code of the tikz-qtree is printed.

julia> using TikzQTrees, TikzPictures

julia> tree = SimpleTree("root", [SimpleTree("left"), SimpleTree("right")]);

julia> TikzQTree(tree)
[.root left right ]

julia> save(SVG("test_tree"), TikzPicture(TikzQTree(tree)))

The saved plot is:

One more thing

This package additionally provides the macro @qtree for pretty printing of Julia's syntax trees:

julia> qt = @qtree a * (b+c) == a*b + a*c
[.{==} [.{*} {a} [.{+} {b} {c} ] ] [.{+} [.{*} {a} {b} ] [.{*} {a} {c} ] ] ]

julia> save(SVG("distributivity"), TikzPicture(qt))

TreeView.jl is a related package that implements a macro @tree which is build on top of TikzGraphs.jl.

Used By Packages

No packages found.