Skip to main content

Sankey plots with Matplotlib

Project description

mpl_sankey

This is a simple package to produce sankey plots with matplotlib. It is an alternative to the matplotlib.sankey module, which sacrifices some flexibility in exchange for a much simpler interface.

Specifically, this package only produces standard horizontal sankey plots, but it does so automatically from data, rather than requiring the user to figure out the spatial distribution of nodes/flows.

How it works

There is a single method, sankey(), which accepts one argument data and several optional keyword arguments.

data must be a 2-dimensional tabular object: best results are obtained with pandas.DataFrames, but numpy.arrays and simple lists of lists are also accepted.

Installation and dependencies

You can install this package through PyPi with pip install mpl_sankey.

The package requires pandas (and, obviously, matplotlib) to work.

Example

data = pd.DataFrame([[1, 'a', 1, 'I', 1, 'success'],
                     [2, 'b', 2, 'III', 2, 'discard'],
                     [1, 'b', 1, 'II', 2, 'success'],
                     [1, 'c', 1, 'II', 2, 'discard'],
                     [2.5, 'a', 2, 'IV', 1, 'discard'],
                     [2, 'a', 1, 'I', 1, 'success']],
                    columns=['Weight', 'First', 'Then', 'After', 'Finally', 'Outcome'])

plt.figure(figsize=(12, 3))
sankey(data, cmap=plt.get_cmap('viridis'))
plt.savefig('featured.png', bbox_inches='tight')

Find more in the Examples notebook.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpl_sankey-0.0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

mpl_sankey-0.0.1-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file mpl_sankey-0.0.1.tar.gz.

File metadata

  • Download URL: mpl_sankey-0.0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.3

File hashes

Hashes for mpl_sankey-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b40cf48134b33a3bc6eeb6497be00ecdb00b3560507efed99736bcf9b1df4dde
MD5 bc3514a0c51eb740b340a447830b123a
BLAKE2b-256 49c1e6f7924db99a7b0542bcc5a84eb99c7837590e4d571d926472b8c47f714c

See more details on using hashes here.

Provenance

File details

Details for the file mpl_sankey-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: mpl_sankey-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.3

File hashes

Hashes for mpl_sankey-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 14a0198f2714c53d8c0127802b849e514306e05a38d55fef5dc4dea1e0f868bb
MD5 24c9dcb622f949f92d2776014425e769
BLAKE2b-256 de450598d0a8d4b8950bdcda72c1f79e3823f490a7f8d24550cca38c2127de7d

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page