Skip to main content

plotlywaterfall

Description

A small package adding simple waterfall plotting capabilities on top of the plotly graphing package. Waterfall graphs are useful to display e.g. financial data such ans cashflow statements in an easily digestible format.

While plotly includes basic capabilities to plot waterfall graphs, it ships only limited features. The plotlywaterfall package provides simple, plotly-express-style waterfall graphs with grouping, multiple stacked categories and variable colors.

Installation

Use pip3:

pip3 install plotlywaterfall

Usage

More examples can be found in the example notebook (https://github.com/docdru/plotlywaterfall/blob/main/example.ipynb). Let's use this dataframe for a simple yet complete example:

df = pd.DataFrame({
    "X": ["A", "B", "C"]*4 + ["D", "D" ], 
    "Y": [4, 1, 8, 7, 3, 2] + [i-1 for i in [4, 1, 8, 7, 3, 2]] + [8, 5],
    "category": ["one"]*3+["two"]*3 + ["one"]*3+["two"]*3 + ["two", "three"],
    "group": ["Group1"]*6 + ["Group2"]*6 + ["Group2", "Group3"]
})

DF

One can plot this data, with defined colors and automatic creating of total and subtotal, by using:

from plotlywaterfall.waterfall import Waterfall

colors = {
    "Group1": {"one": "red", "two": "blue"},
    "Group2": {"one": "salmon", "two": "lightskyblue"},
    "Group3": "green"
}


c = Waterfall(df, x="X", y="Y", category="category", colors=colors, group="group", total=True, subtotals={"C": "Subtotal"})
fig = c.get_fig()
fig

Resulting graph:

Example

Disclaimer

I might maintain and improve the package. I might also not.

Known open points:

  • It is not possible to have mixed signs per X-value.
  • I am note really happy with the interface for defining the colors.

Changelog

Refer to CHANGELOG.md

Metadata

Release files for plotlywaterfall 0.9.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for plotlywaterfall 0.9.3
File Size Uploaded
plotlywaterfall-0.9.3.tar.gz 66.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for plotlywaterfall 0.9.3
File Interpreter ABI Platform
plotlywaterfall-0.9.3-py3-none-any.whl Python 3 none any Details

Total release size: 72.1 kB

Release files / plotlywaterfall-0.9.3.tar.gz

Download URL plotlywaterfall-0.9.3.tar.gz
Size 66.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bd068ad0ebf536f007e7f2af34d91028111cb2171d6a936a4e1e7890cc3ef127
BLAKE2b-256 checksum
How to use checksums
6978674e1b087fc847a72137aca51cd546681452ba998e53d72361355f1e7f1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.26.0

Release files / plotlywaterfall-0.9.3-py3-none-any.whl

Download URL plotlywaterfall-0.9.3-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ce8b991f636078021d02537edc9b87084c276616f0c01b40a869f6b0911e7e3
BLAKE2b-256 checksum
How to use checksums
fdfda0b1eade227e3b227e9ef562b7c34ee078004a06d6b9e7f47b0d7265aabd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.26.0

Release history Release notifications | RSS feed

This release

0.9.3 This release

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page