{ "cells": [ { "cell_type": "markdown", "id": "3450476b-4442-4058-a85f-fe62318bf4d4", "metadata": {}, "source": [ "# Parameter `base` of the Waterfall Plot" ] }, { "cell_type": "code", "execution_count": 1, "id": "12b11c62-ca96-4170-b170-3621f8443dfa", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", "from lets_plot import *\n", "from lets_plot.bistro import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "bf650dff-1671-4c71-9ccc-16bd70fdeaad", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "9bbe82ee-646c-4343-bd8b-c13189e8854a", "metadata": {}, "outputs": [], "source": [ "data = {\n", " \"Accounts\": [\"Product revenue\", \"Services revenue\", \"Fixed costs\", \"Variable costs\"],\n", " \"Values\": [830_000, 290_000, -360_000, -150_000],\n", "}" ] }, { "cell_type": "markdown", "id": "ccb69f6a-4946-4aca-aeed-12216c172268", "metadata": {}, "source": [ "## Default View" ] }, { "cell_type": "code", "execution_count": 4, "id": "291034ab-767e-479a-9016-c8f7b807ecea", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "waterfall_plot(data, \"Accounts\", \"Values\", hline=element_line()) + theme_minimal()" ] }, { "cell_type": "markdown", "id": "fca89d1a-6b5a-4393-a420-47c33381c7fd", "metadata": {}, "source": [ "## Change Base" ] }, { "cell_type": "code", "execution_count": 5, "id": "d4836173-0cd3-4831-bdb3-873f76b3e987", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "prev_period_total = 400_000\n", "waterfall_plot(data, \"Accounts\", \"Values\", base=prev_period_total, hline=element_line()) + theme_minimal()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.20" } }, "nbformat": 4, "nbformat_minor": 5 }