Skip to main content

Sugikey

Description

This package aims at providing a reasonably simple and flexible way to draw Sankey diagrams and related flow diagrams in Python. Sankey diagrams are flow diagrams composed of arrows of width proportional to the flow of e.g. energy or mass. We use the Sugiyama method to derive layered graph layouts, hence the portmanteau Sugi(yama)(San)key.

Some key facts:

  • Consumes pandas dataframes or networkx directed graphs as inputs.
  • Uses NetworkX for processing of the underlying graph structure.
  • Produces visual output with Matplotlib.
  • Limitation: the created diagrams are not interactive, i.e. the arrows cannot be moved. Interactive Sankey diagrams can be created with a variety of other tools, including d3-Sankey.

Have a look at the documentation for more information.

Visuals

image info

Installation

The simplest way to use Sugikey is to install the pypi package: pip install sugikey.

You can also use the Python code from the repository, provided you have installed the required packages. We use Poetry for dependency management.

You will need Python >= 3.10, as well as NetworkX, pandas, Matplotlib and PuLP for layout methods using mathematical optimization. The dependencies are managed with Poetry, which you can use to install the package (see poetry.lock and pyproject.toml).

Usage

The simplest way to use the package are the high-level functions sankey_from_dig and sankey_from_df, which take as input a networkx directed graph and a pandas dataframe, respectively.

import pandas as pd
from sugikey import sankey

# Sankey diagram from a pandas dataframe
flow_df = pd.read_csv(csv_path)
sankey.sankey_from_df(flow_df)
from sugikey import sankey

# Sankey diagram from a networkx directed graph
dig = examples.balanced_tree_with_cross_edge()
sankey.sankey_from_dig(dig)

Have a look at the documentation for more information.

More on Sankey diagrams

Support

Write an issue if there is an issue.

Authors and acknowledgment

Zlatan B.

Project status

This is a personal project without any guarantee.

Metadata

Release files for sugikey 0.5.0

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

Source distribution (sdist)

Source distribution for sugikey 0.5.0
File Size Uploaded
sugikey-0.5.0.tar.gz 19.6 kB Details

Built distribution (wheel)

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

Total release size: 41.3 kB

Release files / sugikey-0.5.0.tar.gz

Download URL sugikey-0.5.0.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
04e777fc4aa21dc34a7c8881c5bd4c6a4c4708cb2f502320c04686555e2cb47b
BLAKE2b-256 checksum
How to use checksums
19c859c5508ce69d419ec4b2076e054e326e6759634cbf151754a84ced96dcca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / sugikey-0.5.0-py3-none-any.whl

Download URL sugikey-0.5.0-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47ada526930f5dd9ac0235425a553e3d9fd29cbdc3957ea47af8742f39560d94
BLAKE2b-256 checksum
How to use checksums
c2265e49bb21afbb37af518cded0eb36e9cb8c3e8350734f712d9c1ecd9fbba2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.0

2 release files

0.1.12

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.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