This module allows the user to plot a phylogenetic tree on an existing matplotlib axis.
This means that:
- Phylogenies can be incorporated into existing plots.
- Annotations can be added using standard matplotlib functionality.
- Plots can be output in png, pdf, svg or tiff formats.
- Automatically generated and updated figures can include phylogenies
Full documentation is available via ReadTheDocs.
The module depends on the ETE Toolkit, an excellent existing Python framework for analysing and visualising phylogenetic trees, plus the matplotlib visualisation library. It is designed to make generating complex figures incorporating phylogenies easier, as matplotlib plotting functions can be used on top of the basic tree.
Requirements
- python >= 3.6
- matplotlib >= 2.1.1
- ete3 >= 3.1.0
The module can be installed using pip
pip install plot_phylo
You can also download the latest release here
Or clone the GitHub repository directly.
git clone git@github.com:KatyBrown/plot_phylo.git
For detailed usage instructions, visit our ReadTheDocs page.
To draw a phylogeny under the default settings onto a blank figure.
import matplotlib.pyplot as plt
import plot_phylo
# Create an empty plot, 8in (width) by 10in (height) - matplotlib
f = plt.figure(figsize=(8, 10))
# Add an axis - matplotlib
ax = plt.subplot()
# Plot the tree on this axis, using the default settings - plot_phylo
results = plot_phylo.plot_phylo("examples/primates.nw", ax)
# Save the tree - matplotlib
plt.savefig("examples/basic_plot.png", bbox_inches='tight')
If you use this repository in your work, please cite:
Brown, K (2024) plot_phylo. https://github.com/KatyBrown/plot_phylo
I use GitHub Actions for continuous integration to ensure code quality. You can view the configuration here.