{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Preamble" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from plotapi import Sankey\n", "\n", "Sankey.set_license(\"your username\", \"your license key\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction\n", "\n", "In this notebook we're going to use Plotapi Sankey to visualise some of the Apple's filings for the third quarter of 2021." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Dataset" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The data can be found in the 10-Q filing dated the 28th of July 2021, i.e. the [quarterly report](https://investor.apple.com/sec-filings/sec-filings-details/default.aspx?FilingId=15115175)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "links = [\n", " {\"source\":\"iPhone\", \"target\":\"Total Revenue\", \"value\": 39.6},\n", " {\"source\":\"Mac\", \"target\":\"Total Revenue\", \"value\": 8.2},\n", " {\"source\":\"iPad\", \"target\":\"Total Revenue\", \"value\": 7.4},\n", " {\"source\":\"Wearables & Accessories\", \"target\":\"Total Revenue\", \"value\": 8.8},\n", " {\"source\":\"Services\", \"target\":\"Total Revenue\", \"value\": 17.5},\n", "\n", " {\"source\":\"Total Revenue\", \"target\":\"Cost of Products\", \"value\": 40.9},\n", " {\"source\":\"Total Revenue\", \"target\":\"Products Gross Profit\", \"value\": 23},\n", " {\"source\":\"Total Revenue\", \"target\":\"Cost of Services\", \"value\": 5.3},\n", " {\"source\":\"Total Revenue\", \"target\":\"Services Gross Profit\", \"value\": 12.2},\n", "]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualisation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's use Plotapi Sankey for this visualisation, you can see more examples [in the Gallery](https://plotapi.com/gallery/).\n", "\n", "We're going to adjust some colors, layout/template parameters, and flip the intro animation on too.\n", "\n", "
" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "Plotapi - Sankey Diagram\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "colors = [\"#61bb46\", \"#fdb827\", \"#f5821f\", \"#e03a3e\", \"#963d97\", \"#009ddc\",\n", " \"red\", \"lightgreen\", \"red\", \"lightgreen\",]\n", "\n", "Sankey(links, colors=colors, animated_intro=True,\n", " link_verb=\"$\", node_verb=\"$\", noun=\"billion\",\n", " link_numbers_template=\"$bn\").show()" ] } ], "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.1" } }, "nbformat": 4, "nbformat_minor": 4 }