ExamplesΒΆ

Hide code cell source
import math
import pathlib
import warnings

import demes
import demesdraw
import demesdraw.utils
import matplotlib.pyplot as plt

# Output SVG.
from matplotlib_inline.backend_inline import set_matplotlib_formats
set_matplotlib_formats("svg")


# Ignore warnings about simultaneous pulses in our examples.
warnings.filterwarnings("ignore", "Multiple pulses", UserWarning, "demes")


def plot_from_yaml(yaml_filename):
    graph = demes.load(yaml_filename)
    log_time = demesdraw.utils.log_time_heuristic(graph)
    log_size = demesdraw.utils.log_size_heuristic(graph)

    ax1 = demesdraw.size_history(
        graph,
        invert_x=True,
        log_time=log_time,
        log_size=log_size,
        title=example.name,
    )

    ax2 = demesdraw.tubes(
        graph,
        log_time=log_time,
        title=example.name,
    )

    plt.show(ax1.figure)
    plt.show(ax2.figure)
    
    plt.close(ax1.figure)
    plt.close(ax2.figure)
    print("\n\n")

    
# Plot each example yaml in the examples folder.
cwd = pathlib.Path(".").parent.resolve()
examples = list((cwd / ".." / "examples").glob("**/*.yaml"))
for example in sorted(examples):
    plot_from_yaml(example)
_images/e42698c131784b911371f0553655c8c2b34b71137b0e15aaeb96a61325df3559.svg_images/79a4cfccf768ed5d2cea4f9bda6cd7aaa3c2410ca8546860a4057fb1eadfda09.svg

_images/4229f3c5da558ce9c9c5a5354fde524c5aa9bd004403414014e92d288888b9f8.svg_images/52c96e9c298ccd9ded11eaad8f09e53ee2fd70f6f9107eb16240e037b11d0c1a.svg

_images/85e9ae9ca8a8011cc3fe25a77fce22e89798555eaeb2f0e432ddc9223b2904d6.svg_images/8a40dfab3b045a8e0ea1d94e12b34cc0698ed88fc6579bce3b7476b0f2226913.svg

_images/03e8ae8f05b40626c0f654ead94c928e8c0bf780fbcd1237631eeeb2a875c939.svg_images/4a47d6f68f4ac9d98b163f60b5c023e8b668dceaa253c2afabf8fd2682ea3f42.svg

_images/514388fb3d06668aebd2753eb83d977aa2612b8143a830a811e9bb5fea5571d6.svg_images/77d101397257045992d9338e0d2016a17fd5adaa7615f3e11d060c60eb4bf777.svg

_images/4ad651cf72f2d0f1fee80fb2ba1e83c9a6b92f4ac611468f9a0190a952ed22ea.svg_images/c17dba1c2af218dcef441c24d497ad4fb798a634de462036de3cd17f8a3c3d74.svg

_images/781434e0c5a019db6b17eb1a114727784f32d30dc4474eeb22ba9916dc4dfef3.svg_images/ac39c81a5dc3cc00319d17e80c5e5dc6f10bd7aa40dc473f7b5377eecc5bb1f6.svg

_images/374301b9ee21c70dc47cb9e8fe0b214dc5913933fa79258aa754ea063b681bec.svg_images/1d860c066d8060b4bdc1570be968a77ec4650da07d1f250aa80ecf24508b190b.svg

_images/bcf46e0736506cd4db6fa928fd0d22a618cc409edd7e3e49dacc3225d83f0213.svg_images/e1bdc38cb0c572ef78c65c70972218a8990fd96dfad007bfd6770410761f8411.svg

_images/4855584477e6c97ac9ded83e997e9ec0222176a0d964af8c867da4580bf3c1b0.svg_images/5e1e9642891c515f234ba93066cff79dca04c728ceec84a6c3854aa39ee17197.svg

_images/15cad09c4845ce5538e81dfaa5a979ae87aaea7e2175f821f5608244fbec48e0.svg_images/dea14280bb426be054b039f7973e7cecdf2b7232f443b7916c7565abb1330bc7.svg

_images/38d6bdea0f4c629cc0dd50aed4e725a231972dcace0205136826cb4db039184c.svg_images/35cfd6ae4cf6ea0aa7c2355c07ad026c8c1b601f1509a02ad526162b28c1eed6.svg

_images/30a5d69877b6c213df38f3bea3779e640e1b178158d2bbff020022ff7441ffb5.svg_images/54d11054c0b99d3d685557b8ef6f81afbe2f4b644d8690b22eead0e86c8670e1.svg

_images/38f5f79138a182df74f03e7163df675c00fc062f199f3c537fa56dba291d7ba2.svg_images/396cb7242ffc295d9aab5740031cfe9b59ee29ef26925ea1b5debf103c3fe31e.svg

_images/e68b55ae454d7adc28bcb7d0a6d4a026ff2a19445b8005cedc3d59089b8ffe8a.svg_images/f30dfa52e9fc65beece43b4b8a7cab4bc1bb45708067923d3b35594ba52c59bc.svg

_images/b23f2a5ca10b7873038ef373ffbf7fd3a10edda3fdb5bef711fdc69daf12896a.svg_images/61d23a34218abec3cec98b41f2dde89f5ff972f3bff44963450f7397d959b821.svg

_images/3e3cc1ee29664910faa1dcd4f5f7e2dcbe1640bfbef2c6a3820aad0de2be0f68.svg_images/fb589534da13b356e9b89c4512e2765aed15a5c51d673037dd1065af908bd258.svg

_images/08b3559d6dcbefcbd1d5980068f0ef69dd221cd84f297beecef9d5ba0bd673b7.svg_images/4370f6c39c8a9ec4633db210b433304a69725df7ee77825403c8746ac671ca9c.svg

_images/d15fb8fcf2ec9401b2ee7914f34564d38674e323cbb9836cde642b737986b160.svg_images/98d0311726d337775e047fbd3d0b450b708c8bdcbc8ca9c3eb4b2250e5d35940.svg

_images/5e85ac0ffa2e6fd23647aff481b30bb409a6f0655f09867f00f289949a6264b6.svg_images/3b24acf01e9938eea8b913f0cbbf66288e7a7293d5e22dfb24c2b65c6e50d91a.svg

_images/d06832e5cf7088c63abda2b6652d719114d2292fe219f8c70e1b623f5be78837.svg_images/31f323abbff6c455e7a9e398919f3ba081f81c3fdb049f81053366f8ca35a9f1.svg

_images/2380871da862687fcfa05b83bba0fbcebe9b87e2a1d60f4c20cca36f7fdf726c.svg_images/d5383060c27c3458455f9f5696529f4f7e28399acbd9d72fe4fa6432e6f44151.svg

_images/1afa3b0a45723083d83bf52e8dd80a020dd44d516edf7d4958f5482c58a57239.svg_images/60755b304028735ac40589497150117241a4a499ee3d5c82c5cec59e8013e0a1.svg

_images/af11fbddaa529e58158270e636703c7f3eee88f1a40e527d1df400027e01277e.svg_images/64e920cf67c53d76c1033d2d62154ca3165631fb009adebfd4403a437997bd3d.svg

_images/0d2ec80a0d114fe7086011d256e226f388f83cb24b87a51a918f296fafe8aa08.svg_images/bf89fa8f14bbf5760b1dbef2dbcf865c2d869143eeb88faf49f82304a6e1e348.svg

_images/5b163739339eb759b9819a16b08028cb22b0df0dd737a98ed7880ae9c2c6e5fe.svg_images/abff7c37c5e72b9924241744ed1d4043c0b89293931774a1e2e73c72bd76d264.svg

_images/103c9c61802eba07c043a4be09a5055db92ebfe1edec9c5ce2f26acfa0821511.svg_images/0eeb58e766dad0128c67598ad073d198295dd9e0b9d076129576d0f57add52ca.svg

_images/54191ff21b7d9af56f7e7ebe7bdaac38a1abd7959e9496294ecf4b55ec0b8d1d.svg_images/a07742a642fe04c389214c2d47e4d1c76f16f395128782eff8b9fb5ecc84ac65.svg

_images/f422baa30c2716cac2fef0b6aa5b42ffe7f332de13b977f34e3eb362b5784740.svg_images/abaad6befe91ee68dc9133523a0d42eb0457fd0fdc2d7ef4b2f3cbccf6100a39.svg

_images/6eb608da971ffee51cd4f9e945524cf5cab9eeeaecffaebcdc4b3f19456cba39.svg_images/bc2dcadd670baa1a77c8f8b843a9d1a78481446a572b6c01a271484179fe7891.svg

_images/ab4558c08e490cfdf898d0b38470b529b5130b49debcc991029beaacc9baaf2f.svg_images/389141ed06ad45039d52a8435bad4ff110b2eb40e949cac47c7cb6830682bf65.svg

_images/481010e81eca212e69a6144480681e1fd608001cbee80cfbe0672dbe436d19eb.svg_images/d3f2efcf26c9089ea563c164f2b09ad570fdfd246b6eb1ac7366e61c7e1afba0.svg

_images/0f5d6e48378affe8ba94d35d2c3da83d67c01b5a773f546ed5a017da2f8b0715.svg_images/764d5ce80bf9608b23d9f3d31ebf3f355445c63e5893f5b778dab03d7590003b.svg

_images/33f5ed28777fefd992f54d1563a735aa41888ade3f6479d268d66f9d52fd3652.svg_images/28689cfd358dfc24e03f7aa8e3b0a08c1e2244e044698942ebb2b10396e470cd.svg

_images/c45b62be602e26004725b0b2fd3fef09215b1c18e58cf787a7f58d10b5116ae8.svg_images/26543fc44bcd4498527a9857dc6de024a58d1fd1a5ebb87db2539e6b9fd86985.svg

_images/6da92cab573519bc61809a749c6cab31258bb488faba8e1cd73a00e3fddf514f.svg_images/8ffaae3a2baeea7b3fcb7cb3932aafb2cd735e007163704926a0abeb47b685d0.svg

_images/2c2c17d82df200026a270b45a2650039be07f598456ff221ee366472fa257407.svg_images/c50460dea0b22ae9f0a13ea9d8812e2edb7cf089a032cfc5828c9df3916b4b8b.svg

_images/6725f99d41fd4b3bb7e7a2f67b40a4ded4857f820250c76d4247831c68e9803a.svg_images/a348cd944f144796bb09fc733a63cf7645b3968b7cd8b7ad8528dde0d3c30cfe.svg