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/7c38ca77a1ee4ec8735cee0bb1b632e681a85eefcab8336f535ca3f1ffad350c.svg_images/158d6404ceecf8506e56b2a608ca3df534097a491041f149b826f6c57f08ed75.svg

_images/0306c123e392821fb60f7de4f6ccbdf2269028fa4f61941e437488baf52676dc.svg_images/c5cf8454f5e371b9baae7f7fb1c8670e7f4723575a5c769ed677e3146ebc3766.svg

_images/b4997f58d957bb02e52f8f1fd4748f33093e7f6706bb11b6e9582b29e92241a4.svg_images/e14f92fa31a88c4e5b5c86b1f9e5644a2fe78a9ae6284f61ef5dc72ae8bcdb3d.svg

_images/7b8ad5d68334a8261cf68a06003d34442f31413e0524074d742a5ea5cb7cd063.svg_images/bd5cd356973cfde93531dff7de717f475d669259412c80a4b8bab3c2f021974a.svg

_images/b10b30dbcca2955d4a5667537ab4edaf0edd6de1729bdbad9f5f09a862454f6b.svg_images/90fe33ec770db7eb460101c159d24bff50fb25d7cc1a83ae5d975e43b7c4ba9d.svg

_images/0567cf738f48a3e764c20d12b175c05f2e63fcd9fd1836dd1a0f9420473e4690.svg_images/b733e9f67f3700563cdcd048e2da70bcc446308b3aa29abc2a8144f6dbcaac4e.svg

_images/d0a76ae51da0d678966c0221344e94cf56fcbd699f9bfbf2770050da24fe93ab.svg_images/dc4165baf6a392275e1877fdee1c288fc8006b24a6ea8128677bd9eb270784f8.svg

_images/20c39646e26a299cffce5707fcc59849548243f41da06bce753f2edb6fc0b63b.svg_images/1964a910921194bac13e70d9300d8ce970cb3830e9bb695d6b2b98adf87a8c10.svg

_images/3b4cb84581c936c77706a3c12531c096c119dd56eeb659b718381290d6c7c007.svg_images/798deddc615abe3132fb1ca00541128e9e19eba5dab789cb7759acc833ca47eb.svg

_images/32ef7e2e1de120e559f940016bc2dff5a79ae9e9d920aa095f94acec3beece2a.svg_images/ea846981ec158bbb0a103657606390b8f4e95898a9c490fd861d5ce1ee8db5f9.svg

_images/105ed005edda15eff69f8fe9c75417de486f650ede06172dada442102f67ba31.svg_images/96077df0eb389b89bacb10fde17d924c6fa85cf0b4ccc1a7b53de23d0703a703.svg

_images/1cb97b0e6f918e80c9844f7ddf037f1ef16c905e90e100c8e4565e770e717d50.svg_images/a15cea4823d23b9f7c6052d07f214b77447354cffaaba72f414f4e522321a07c.svg

_images/5fac8be783a5a4e89196229cbe34744ce117146f77c27ba0004f8ecded163613.svg_images/e931fd12e09fed377fe1040020a6de5866fe91e11a86cdad3951245ab03b0f05.svg

_images/fe95c32c45b766d2beafc1a2a64a388dc3a1f860fecdf3889f257d058d52a056.svg_images/f41365f1093c214a18ee244df84f266bdb4e8c5e2919f8e08d4dc901247ad654.svg

_images/2347dc1a5711048e1076ea746d9e4695815a9b3de916199a174aca9755aa81da.svg_images/10a9735f3203996d1d17f7d03ae688da719eae46095dc6b2a0fa2e1f6efebb5b.svg

_images/86fda4d81187ff908d6520a8abbaa70871edd21330669b73f945c63d731161f9.svg_images/dbf50a0a5128238924abd05cbeefcbe5093eba9aaccabd95cc728d281d6b0e40.svg

_images/6a10698e7a4c3d91ca88e530729b583d9ab107aada5425a5ad627fa60e8e21b8.svg_images/1e3a22dc8d9f818153bdf983c64d3a82e4b3ff336f445beda8e5600f2ad39e2e.svg

_images/d6c1a4ce434ed7fe7f6a1fcea020e7723a21b90a49d8606c5a71d5c9332835d7.svg_images/84073a4df5e29c22333747d719eff3c0dfa560343de5d9e979daf72cb140bd76.svg

_images/ffa7d2e515d07e3589c5290e2f4f7d4ca4e485d965acbef9777cd65ff4be867d.svg_images/0da791edc415b878b4a7638578e84eb85042eb79d457e483597dfd21ec65e860.svg

_images/4f1ba23cee44cf7d30c721dbb66d826ea79890c953f9377fa7fa5b52764c087a.svg_images/f0c09a73bf660e3a28a18772a8c393bb3f8911f244f2407e5cb11a0cd0180d2e.svg

_images/22f010278dc5682147233cbf33a2284c041719e210a749c37d9bdf04276b800d.svg_images/8846ce38bc76ddd2d1169fa1b770288e2286a6453121253418df15c4c840d6ab.svg

_images/12b4d8144a635253dd0a0dfa16c014352c4a12a24bd8c0a6a696d682d1a88f04.svg_images/07b02573dfbedf922a89c24ff09260e2b2e951abeb55104223dcfa5a176ca551.svg

_images/4fb81d8147f030ee82a14a6bb561d8badf921509afb6bb1394d6c6da7413f59c.svg_images/0463c8764dd8cb1d53565e09b3e98cc14e03231fe01ae9340c9f472ba9b631f2.svg

_images/e91f200b6dc01f8c92ad5d387434007b25c4bdd1b2641fc41d51aaa0127a7ef2.svg_images/4b6442cde48b50bf4db5999df5a61b4edb5b75e9e40c03426f0b43fc6992dd01.svg

_images/08e53f1a65d8f4130b85db2fb3b512e3944c7b1cca2884b9d851bda82cb70405.svg_images/7fe788445ca0c39476873f41452a0c7fc0bc61abebce81473bba4d8061d2c67b.svg

/home/runner/work/demesdraw/demesdraw/demesdraw/utils.py:582: UserWarning: Failed to optimise:            message: The maximum number of function evaluations is exceeded.
           success: False
            status: 0
               fun: 267700252081.24774
                 x: [ 2.580e+04  2.580e+04 -1.061e+03  5.266e+04 -1.446e+05
                     -4.599e+04  1.513e+05]
               nit: 1000
              nfev: 1000
              njev: 7223
              nhev: 0
          cg_niter: 3236
      cg_stop_cond: 4
              grad: [-1.379e-02 -1.095e-02 -2.638e+04  1.201e+06 -1.870e+06
                     -4.889e+05  1.184e+06]
   lagrangian_grad: [-1.380e-02 -1.095e-02 -1.120e-02 -1.120e-02 -1.120e-02
                     -1.120e-02 -1.120e-02]
            constr: [array([ 5.372e+04,  1.973e+05,  9.865e+04,  9.865e+04,
                            9.865e+04,  2.960e+05,  1.973e+05]), array([ 2.580e+04,  2.580e+04, -1.061e+03,  5.266e+04,
                           -1.446e+05, -4.599e+04,  1.513e+05])]
               jac: [array([[ 0.000e+00,  0.000e+00, ...,  0.000e+00,
                             0.000e+00],
                           [ 0.000e+00,  0.000e+00, ...,  0.000e+00,
                             0.000e+00],
                           ...,
                           [ 0.000e+00,  0.000e+00, ...,  0.000e+00,
                             1.000e+00],
                           [ 0.000e+00,  0.000e+00, ..., -1.000e+00,
                             1.000e+00]]), array([[ 1.000e+00,  0.000e+00, ...,  0.000e+00,
                             0.000e+00],
                           [ 0.000e+00,  1.000e+00, ...,  0.000e+00,
                             0.000e+00],
                           ...,
                           [ 0.000e+00,  0.000e+00, ...,  1.000e+00,
                             0.000e+00],
                           [ 0.000e+00,  0.000e+00, ...,  0.000e+00,
                             1.000e+00]])]
       constr_nfev: [0, 0]
       constr_njev: [0, 0]
       constr_nhev: [0, 0]
                 v: [array([-2.638e+04, -1.014e-06, -2.359e+06, -1.184e+06,
                           -1.870e+06, -5.068e-07, -1.014e-06]), array([-6.531e-07, -6.531e-07, -8.801e-07, -5.041e-07,
                           -8.073e-02, -1.763e-06, -2.146e-07])]
            method: tr_interior_point
        optimality: 0.013795645412239533
  constr_violation: 45990.61737782677
    execution_time: 3.8026137351989746
         tr_radius: 6039085.662223612
    constr_penalty: 26333.43775024477
 barrier_parameter: 0.1
 barrier_tolerance: 0.1
             niter: 1000

Please report this in the issue tracker at https://github.com/grahamgower/demesdraw/issues
  warnings.warn(
_images/bae905c8b44301fafee8e69d48285ab9942187413e2067e9ba5d97112db87ab5.svg_images/2d27b862c48d17ed67716b201a1b01124aa950dbdba2d368efa2299783fb0b1e.svg

_images/95183dcc4bf27e534565acfb9fc7467c27971322f5b4325f5a338f3f088c696b.svg_images/f1614b60c5dc007c68c3beb900d8ad5ab3dcde900f521199b70874e86b4c6018.svg

_images/0d1b1752739421669b9fc45c14da757ebbeb86cfe7417c14843cd9c0160a5a3b.svg_images/e507059673896aa8068084ecb0b8832900bbd118f3b11b3cca042dfb1e223c34.svg

_images/aac6b6d139b5b0b5776c0f23e1ad361b61c2d77c5eef01f63bd871cb893d8b74.svg_images/20a6121ca27285b64c882d4acadd6e534320c2fb7b00ea30c92aa32e86e4e6d8.svg

_images/18080e21f8db705aed59551a7689780c90fc97ba01ff425498d562b69de1f04c.svg_images/34e71e67aa0ea51bdb9b7539e2e4a6b2b219af531281e6d8e9b023c328f6debe.svg

_images/890e907d32cd67fff3b5022c0fa84d73e852e75d20ff278a762a18aece71ef5e.svg_images/59a110379e3810b6026b90a7cdc32eacabf7c4722576da37283f9c387e5dfa13.svg

_images/a0d6543b34c22291ba9504fbd0b63fcc3cfe6710f6a61c25b7f6a64476550a24.svg_images/d48d3c978684c42b2e8d81f140918f2022e45aa8b2506f8d72ca4c751786472d.svg

_images/6248d7468f3ceebd4b0457fb70f881e03388817d1dd70d107dd193833b4a39b3.svg_images/33dd115c95fdba21133202e8cf78dec749a0f7a3eb952f6ef20abfa136b8820a.svg

_images/f0295c52d6e53087425c067c517b069ecefeb3fc6dba3d2c57d0de6bf81b8335.svg_images/dfbee39e9e408d56a24b8edfc23e0cdd22c2f7f7f43d60f5ea54fce50db54660.svg

_images/726646fcf193466f7580e527984c087cc226400f4eb906be982d74b9d2373b8f.svg_images/d71a6c5cdfe13156033ee0e29b9290bb05a0835865f32502001bdb4214c1124b.svg

_images/b2a369ca51383105e814c94fcf809484ed762becb4aa4e29005f119d1d40e549.svg_images/3649c4879b44852930ed16bd3abefd863574bea06c4bc4d986930cd593d80e31.svg

_images/10839afb15418607ba2b3127eac0943984b45ef73201ff33ba8cd26ede2d47d6.svg_images/74d015a0468e182a1f8b7f2d2e2f45a87f8c3aa503f6f87a192a4d75b1618e2f.svg

_images/eacbdfc7248467ffffe1c5f0817c7fc938d6953d3d459bb3827d385ac6151dd5.svg_images/c32e52a6c1ffd65dcdb46ac51085c44db27a08722a7fe2d6ec1c7328395b6efc.svg