Get the Books

Enjoying these notebooks and want to support the work? Check out the practical books on Data Science, Visualisation, and Evolutionary Algorithms.

Get the books

Apple's 2021 Q3 Results with Plotapi Sankey

Support this work

You can support this work by getting the e-books. This notebook will always be available for free in its online format.

Preamble

In [1]:
from plotapi import Sankey

Sankey.set_license("your username", "your license key")

Introduction

In this notebook we're going to use Plotapi Sankey to visualise some of the Apple's filings for the third quarter of 2021.

Dataset

The data can be found in the 10-Q filing dated the 28th of July 2021, i.e. the quarterly report.

In [2]:
links = [
    {"source":"iPhone", "target":"Total Revenue", "value": 39.6},
    {"source":"Mac", "target":"Total Revenue", "value": 8.2},
    {"source":"iPad", "target":"Total Revenue", "value": 7.4},
    {"source":"Wearables & Accessories", "target":"Total Revenue", "value": 8.8},
    {"source":"Services", "target":"Total Revenue", "value": 17.5},

    {"source":"Total Revenue", "target":"Cost of Products", "value": 40.9},
    {"source":"Total Revenue", "target":"Products Gross Profit", "value": 23},
    {"source":"Total Revenue", "target":"Cost of Services", "value": 5.3},
    {"source":"Total Revenue", "target":"Services Gross Profit", "value": 12.2},
]

Visualisation

Let's use Plotapi Sankey for this visualisation, you can see more examples in the Gallery.

We're going to adjust some colors, layout/template parameters, and flip the intro animation on too.

In [4]:
colors = ["#61bb46", "#fdb827", "#f5821f", "#e03a3e", "#963d97", "#009ddc",
          "red", "lightgreen", "red", "lightgreen",]

Sankey(links, colors=colors, animated_intro=True,
       link_verb="$", node_verb="$", noun="billion", 
       link_numbers_template="$<plotapi_value>bn").show()

Support this work

You can support this work by getting the e-books. This notebook will always be available for free in its online format.

Plotapi, beautiful by default.

Let plotapi do the heavy lifting – enabling beautiful interactive visualisations with a single line of code (instead of hundreds).

Get Plotapi