Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dharasim/tikzqtrees.jl
Plotting trees using the latex package tikz-qtree
https://github.com/dharasim/tikzqtrees.jl
Last synced: about 1 month ago
JSON representation
Plotting trees using the latex package tikz-qtree
- Host: GitHub
- URL: https://github.com/dharasim/tikzqtrees.jl
- Owner: dharasim
- Created: 2018-08-24T17:15:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-27T14:36:01.000Z (about 6 years ago)
- Last Synced: 2024-11-10T06:17:16.675Z (2 months ago)
- Language: Julia
- Size: 23.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TikzQTrees.jl
[![Build Status](https://travis-ci.org/dharasim/TikzQTrees.jl.svg?branch=master)](https://travis-ci.org/dharasim/TikzQTrees.jl)
[![codecov.io](http://codecov.io/github/dharasim/TikzQTrees.jl/coverage.svg?branch=master)](http://codecov.io/github/dharasim/TikzQTrees.jl?branch=master)Plotting trees using [TikzPictures.jl](https://github.com/JuliaTeX/TikzPictures.jl) and the latex package [tikz-qtree](https://www.ctan.org/pkg/tikz-qtree).
## Installation
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](https://github.com/JuliaTeX/TikzPictures.jl). If you can install TikzPictures, you should also be able to use TikzQTrees.
## Usage
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`:
```julia
mutable struct SimpleTree{T}
value :: T
children :: Vector{SimpleTree{T}}
end
```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
julia> using TikzQTrees, TikzPicturesjulia> 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
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](https://github.com/JuliaTeX/TreeView.jl) is a related package that implements a macro `@tree` which is build on top of [TikzGraphs.jl](https://github.com/JuliaTeX/TikzGraphs.jl).