Skip to main content

drawing tools for Demes demographic models

Project description

DemesDraw

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.

Installation

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 \
	AmericanAdmixture_4B11_tubes.svg

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")
ax.figure.savefig("AmericanAdmixture_4B11_tubes_custom.svg")

stdpopsim/AmericanAdmixture_4B11 tubes_custom

Documentation

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.4.0.tar.gz (283.4 kB view details)

Uploaded Source

Built Distribution

demesdraw-0.4.0-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file demesdraw-0.4.0.tar.gz.

File metadata

  • Download URL: demesdraw-0.4.0.tar.gz
  • Upload date:
  • Size: 283.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for demesdraw-0.4.0.tar.gz
Algorithm Hash digest
SHA256 9fb773fa461fdb2cabeba4c1c78e765bacf8a93e9b4fcd6ed09e1a30062e1827
MD5 934bf1693f6bf78f88b88f484a95932b
BLAKE2b-256 669475d488794b168a193e2f86fe8bc6e3a0b2c8c8cb59c9261c46587644785e

See more details on using hashes here.

File details

Details for the file demesdraw-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: demesdraw-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for demesdraw-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f27745622c1b6ccd1f0e263dad7d150e28180599fc8e24c32a2c215648f76d3
MD5 8cb0c2a4b40124c72996f6323fde732a
BLAKE2b-256 b175c9cf4df087dd7229b267e856887d61a31cfafc21de25e98e56e3243f7680

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page