> For the complete documentation index, see [llms.txt](https://vecco-insight.gitbook.io/crash-visualization/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vecco-insight.gitbook.io/crash-visualization/plotly/6.5-financial-charts/6.4.3-waterfall-chart.md).

# 6.4.3 Waterfall Chart

A waterfall chart is a form of data visualization that helps in understanding the cumulative effect of sequentially introduced positive or negative values. It shows how a value changes after being affected by various factors that either increase the value or decrease it.

Let's use a company's financial statement for example.

### 1. Vertical Waterfall Chart

{% hint style="info" %}
**Measure in the waterfall chart**

* Relative: default values
* Total: to compute sums
* Absolute: to reset the computed total or to declare an initial value
  {% endhint %}

```
import plotly.graph_objects as go

fig = go.Figure(go.Waterfall(
    name = "Company A", orientation = "v",
    measure = ["relative", "relative", "total", "relative", "relative", "total"],
    x = ["Sales", "Consulting", "Net revenue", "Purchases", "Other expenses", "Profit before tax"],
    textposition = "outside",
    text = ["+60", "+80", "", "-40", "-60", "Total"],
    y = [60, 80, 0, -40, -20, 0],
    connector = {"line":{"color":"black"}},
))

fig.update_layout(
        title = "Profit and loss statement 2020",
        showlegend = True)
fig.show()
```

![](https://998709212-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB-ky7fVqjeXA6EcAbW%2F-MD6_Y45YasSQmSdmzeK%2F-MD6apyx3iddGbpmH1Ma%2FScreenshot%202020-07-25%20at%2021.19.57.png?alt=media\&token=86d69bc4-b6f3-4741-ada0-8c4c3d1dc4fd)

### 2. Horizontal Waterfall Chart

It's also possible to create a horizontal waterfall chart. If the variable is more than 5, I would recommend using a horizontal one.&#x20;

```
fig = go.Figure(go.Waterfall(
    name = "2020", orientation = "h", measure = ["relative", "relative", "relative", "relative", "total", "relative",
                                              "relative", "relative", "relative", "total", "relative", "relative", "total", "relative", "total"],
    y = ["Sales", "Consulting", "Maintenance", "Other revenue", "Total revenue", "Purchases", "Material expenses",
       "Personnel expenses", "Other expenses", "Operating profit", "Investment income", "Financial income",
       "Profit before tax", "Income tax (19%)", "Profit after tax"],
    x = [300, 150, 80, 20, None, -280, -50, -82, -14, None, 32, 89, None, -58, None],
    connector = {"mode":"between", "line":{"width":4, "color":"rgb(0, 0, 0)", "dash":"solid"}}
))

fig.update_layout(title = "Profit and loss statement 2020")
# reverse the Y-axis, make the chart more clear
fig['layout']['yaxis']['autorange'] = "reversed"

fig.show()
```

![](https://998709212-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB-ky7fVqjeXA6EcAbW%2F-MD6_Y45YasSQmSdmzeK%2F-MD6bPHb3P59rMpsKg7v%2FScreenshot%202020-07-25%20at%2021.17.14.png?alt=media\&token=afd98784-e38e-4849-b278-03ba4d71e644)
