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/4b9530552b54fd9980860c4ee36c15dd6aeb949db3c4080ddb674bb4dd31c882.svg_images/25cc6a445cd36ed0481b878d6013c96a8b61246a64eef5c998d205c4103a865a.svg

_images/0baef798c53d220393299208ceb0a0cfc88abd4f76067f408a2313745b89c1d1.svg_images/0b6dae99d89bd46aebfc109214e720fce9e784ccf5646e256da81d9fdaf54cb2.svg

_images/53706da971e25142029402a9f2df4aec19f4aafa9e63f730a8368561b26b8acf.svg_images/631de2f6e226bf24b0de4f18f9a975b78f6708c41ebbcab2cac774b36ec6d9e0.svg

_images/8974e5b12ccf752484e61be5103b6ce1e200ef31b4e48608bc9127e5546f15df.svg_images/5f2aafa47077bb8ebd2f16728532f1cc55c8175d5d4501a29ba1a022e19363c5.svg

_images/8646df4cf97d74fa8315d6be06ed8cb13143a10609923196ea45e5e6f67bec4e.svg_images/8b9b3f29665acdc26c2114d9949ea05efbbe11c136f5d247c76e8e9be68f2441.svg

_images/9bdcdaebfd393de6a4428503d334e15301812970ab8d47baf7b45b7b11b67eb7.svg_images/8a2f65424cf001dc7192e734344ee75181f9af8e1a3200f907d3337436a27eab.svg

_images/de1415f1a40afef32e56d0db7e98af49bef32456373a15dd0cd3ba40e82afce9.svg_images/c78cdf6d64cfa5c6a483ea64315762bf629252997b68e681cd744701b136f6fd.svg

_images/c75d8bce297d974feec091dec9e4a5d76547812917eb5a78d7a24189b41efb39.svg_images/dfb9b6940d756c4b8ffa5e840e0f2acb6397b363c5e630c61422613bbd48f74a.svg

_images/e94d33a1514001d983d2e93cfde7a111556f60dc52f31f93b4f9c4ac4d710e9f.svg_images/0d22289f98fc031ae35d9b854ed30d95ad1013b1dbfd7a3a678295f3dd102da2.svg

_images/9027d2e5c8a4a66450737b679f613a792100b3a8fc099bd44d0dbde1c050d41d.svg_images/10e89ce0ebcd718b39093456421efa02f5cb575a4ad71f13fda04f5373b812d7.svg

_images/9f5072ce6187e0f89a69250bc70dfbcf03ff40aa6cacd010aa250233a5c1bf8d.svg_images/b5db1b28f818a46336c5a4af66fb9b917ff64be96613716413c6f7d0c88384b1.svg

_images/c7f40707fd8afab9a5d1131222783040e27f6bdfbaf705d81c59ba3c04249e5c.svg_images/792175649ba4bb58180f75447eb85e3cac435f3a7e2f2ea208d441b766052054.svg

_images/7d7a80c2866862638f4ae60a1232d1be6671c959da948d966e20bc2503da7513.svg_images/6d47fd7b234733f65a5874814497a32a7465a2dc6898df29c34ea4ceb24a6ca7.svg

_images/6ca3c54efd13c23170b3d827814664e726f1fb2418eddc0ff7f3b41770a64c6a.svg_images/2349419800397f3ce8aaccb432351d653c812f379959d8454d3a2fae761be5d6.svg

_images/137fb962698ffed53260f2b53bc6dec3e06dc919f54dfb162d232a5e473e3714.svg_images/2e81c2fd3a9556f3ffd52445ae0d5502ffccbf131481783e0a3dc916abd7fdf2.svg

_images/22ef27a08639165190150bb711722c68fea80bde2ca3ed1c4fe4bb16c6a84b72.svg_images/171a090d2b4804c666596f63875aee67546b5922f1d8071a48987af536b78bd0.svg

_images/2627f4400311724f612952f1d8f6bdbe91dd54859f08e71eb18a3cedbbfc664f.svg_images/f72ac20a3c3247784ce338fc378ecd62d7bd94c552ab18694e15f2ca700d5606.svg

_images/17fa9ddf810ec95ec69bcd6165020b9f4af3307127423de3021f07dde2791dc9.svg_images/59bbb4ccfba2a5c01e66cf17cd54455dcf7bcebd00db45d15bef671ce5a14787.svg

_images/0473b917ed92b0f780f7d356c29a903208c37ace3b9844d49147dc9064890039.svg_images/8af9d0db6cb5a9447d6fda1d9a652b48732eee04123b1e574ca2fb5da94d488b.svg

_images/967edef753f58b562af69c1f0e045523847dac29f1cf62804f36e9175c83bf87.svg_images/699a11ecf6db84b2803eb9b24b9aa00e6424c93d7dcac1987df8e26ed6eb35e9.svg

_images/2af971a77f8e6ff5f395f2b0b4cf40585991f05826c51210a6dc427a9e2d015e.svg_images/6473e9fcc1570918a9b63fe54be083e988b08fbec7030c9bca476e5e3a2d1702.svg

_images/2f2a3b77c1b5b494d568c9727c4050291ed77a04afde290d6f5fb5d4dfdf8ceb.svg_images/7599853bd78c39b956233b95df43d49aa28958511a5360ae81b94d162ae9be59.svg

_images/5c0cc98166e16359903eed7b3ce275388b05275620d22bca2d3e538b7575a791.svg_images/ca24b82abd7d29d895fd8dc1e9664694f0079790eed860472a75de56142f34b0.svg

_images/2e95e5b894cf4812e67a6d14612c7097c62e51575e238b8c7cac8558fce31159.svg_images/1f99d1a38e1ee605920d6c3628b86e5c8469c070907f72cc3778b217c13e663a.svg

_images/fdf961469cad79366c5637730e0ae545813fd79108d3e68ed5435da80d3844a7.svg_images/89429016c683cab738d7381262d16f8cae78739d3b13c9bd8b70b341a25f8047.svg

_images/af77d79e7494ed4d1ec23ed3f2f02f0631b521165527fef34300cc1adc4a8b64.svg_images/06bdf935ea4c6cadff99d203355463c14152c36822e7664341f0859ec8e4fe4e.svg

_images/955af68aa7eb633e9164631c370600f6a113145ab19f53997dc9a9cfaf7dc802.svg_images/da6fdb4b2bd8570b4c46fb399adaa6f7364dd8c7c3b84e5fa273b255a4a1ff2f.svg

_images/ce5e0bcab10dad53770659fb4e7ba9ed33ffc95c0485a61783a1f0703cf4455f.svg_images/dcc4ebf5cb536b989b73b1ce1cfee65579a195f5754c32f03c37728f9be344af.svg

_images/e7b6cb672ab0aae00884a214a76304e1b2809f47c20ad928a7d53381f4ed5ca1.svg_images/965a50f98418bc74c7accc1ae81ea9b4a7737293ce6dba95a77fc3c0913b41ca.svg

_images/d848c33c7dd0c7773eea99d33c3c3e56d4fc0ee991757c51eabc6bfdd2ceeb45.svg_images/22d3402d5b4ca76cf57bf9c758749b9e52b7317c852233e5483fb50ca5b12c67.svg

_images/8f9651ae5369ee9fc6c724fed850cf9c3d7dc3bb133cd0edb663e12a74759007.svg_images/6dfc7fd6e292cb6582e2f2ce350813ce481db109595c56b379257bc8344e32b9.svg

_images/ecf878f194e3a46d039eaa2662328baea926d5089052a304123f90f54047064d.svg_images/f1ce293999b6bb7a91108af9e5e21ce97c121c096bbb1a03c37e0274fc8d88ae.svg

_images/82b2dba9ebdf33e098c30751ed2c6c54f5d9e5860ecd0e992c45301bda4f2ca2.svg_images/a2b8eca036a649bb790b935bc217e145c8c3819f8e6857a91659ebc1d4ca0035.svg

_images/121ea7c326cc9f9e1250ffbee89a45343c0d82f33cc7916acb268d534a44207c.svg_images/6d3eeabdb022b9df085a038397f4e63b72f3c5e8a40a881fb222bc83f3899b3d.svg

_images/742c9c7494bcb1a67a97441cb6539eec9291a7c0761ae960bf7b3153f650b0e2.svg_images/b99b1dfb59d1121cd2eb872b35a83658e5495324ca46e338618ac7c210d5da5c.svg

_images/6aece9e1d05acb18c64f3fdd4365d9116daee0c693b0e63803082a3f88231087.svg_images/766440ffc590550453c705a2cc439c4431094e79ce56af1060a8128b39ae7791.svg

_images/db92cdeacec7954db554aafdb3fea89ae588681d4b47d223cf24c4d47736d351.svg_images/6607a563b21b946e27a957c75a8fc45790334d7c0b5f21a92bf9a3a241db66e1.svg

_images/9af010a2968e24c0f186789562af8ad2e36dd73cde248fd500fde0958a2ee6ff.svg_images/6dd3ec39e78cef5eaf86f77b04d757fa8f9fe442729cf8dc80cc3d6a0e1e256a.svg