.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated_examples\simplelife\plot_simplelife.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_generated_examples_simplelife_plot_simplelife.py: simplelife: cashflow ========================== Draw a graph of liability cashflows of a simple whole life policy *Run this sample now!* |binder simplelife_demo| .. include:: /banners.rst :start-after: Begin binder simplelife_demo :end-before: End binder simplelife_demo .. seealso:: * The :mod:`~simplelife` library .. GENERATED FROM PYTHON SOURCE LINES 17-43 .. image-sg:: /generated_examples/simplelife/images/sphx_glr_plot_simplelife_001.png :alt: Insurance Cashflows :srcset: /generated_examples/simplelife/images/sphx_glr_plot_simplelife_001.png :class: sphx-glr-single-img .. code-block:: default import pandas as pd import modelx as mx import seaborn as sns sns.set_theme(style="darkgrid") polid = 171 proj = mx.read_model("model").Projection[polid] # Draw NetCashflows Graph data = {'NetCashflows': [proj.NetInsurCF[t] for t in range(50)]} ax = pd.DataFrame(data).plot.line(marker='o', color='r') # Draw componets of net cashflows vars = ['PremIncome', 'BenefitSurr', 'BenefitDeath', 'ExpsMaint', 'ExpsCommTotal', 'ExpsAcq'] df = proj.cells[vars].to_frame(range(50)) df[vars[1:]] = df[vars[1:]].mul(-1) # Change outflows to negatives df.plot(kind='bar', stacked=True, ax=ax, title='Insurance Cashflows') .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.951 seconds) .. _sphx_glr_download_generated_examples_simplelife_plot_simplelife.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_simplelife.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_simplelife.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_