Skip to main content

drawing tools for Demes demographic models

Project description


demesdraw is a Python package that contains drawing functions for Demes demographic models, using matplotlib to create the figures. DemesDraw offers both a command line interface, and a Python API. Feedback is very welcome.


Install with pip:

$ python3 -m pip install demesdraw

Or with conda:

$ conda install -c conda-forge demesdraw

Example usage

Command line interface (CLI)

The CLI can be used to quickly plot a Demes YAML file. Any file format supported by matplotlib can be specified, but a vector format such as svg or pdf is recommended.

$ demesdraw tubes --log-time \
	examples/stdpopsim/HomSap__AmericanAdmixture_4B11.yaml \

stdpopsim/AmericanAdmixture_4B11 as tubes

Python API

Compared with the CLI, the Python API provides additional control. In the following example, the horizontal positions of the demes are chosen manually and the names of extinct demes are moved to a legend.

import demes
import demesdraw

graph = demes.load("examples/stdpopsim/HomSap__AmericanAdmixture_4B11.yaml")
w = demesdraw.utils.separation_heuristic(graph)
positions = dict(ancestral=0, AMH=0, AFR=0, OOA=1.5 * w, EAS=1 * w, EUR=2 * w, ADMIX=-w)
ax = demesdraw.tubes(graph, log_time=True, positions=positions, labels="xticks-legend")

stdpopsim/AmericanAdmixture_4B11 tubes_custom


Complete API and CLI details are available in the DemesDraw documentation.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

demesdraw-0.3.1.tar.gz (276.1 kB view hashes)

Uploaded source

Built Distribution

demesdraw-0.3.1-py3-none-any.whl (21.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page