Skip to main content

Python package for plotting alluvial diagrams with an arbitrary number of layers

Project description

pylluvial

pypi python-version stable-version

A python library for creating alluvial diagrams with an arbitrary number of layers

Installation

Simply run the following

pip install pylluvial

or clone the repository

git clone git@github.com:dmalzl/pylluvial.git

and run

cd pyluvial
pip install .

you should then be able to import the package as usual

Usage

A minimal usage example would be as follows

import pylluvial as pa

data = pa.generate_test_data(
    [3, 4, 3, 2]
)

# by default labels are not shown
fig, ax = pa.alluvial(
    x='timepoint',
    stratum='module',
    alluvium='nodename',
    data=data,
    palette='husl',
    stratum_gap=2,
    stratum_width=2
)

fig.set_figwidth(10)
fig.set_figheight(5)
fig.tight_layout()

# pass show_labels = True to get labelled plots
fig, ax = pa.alluvial(
    x = 'timepoint',
    stratum = 'module',
    alluvium = 'nodename',
    palette = 'husl',
    data = data,
    stratum_gap = 2,
    stratum_width = 2,
    show_labels = True
)

fig.set_figwidth(10)
fig.set_figheight(5)
fig.tight_layout()

# use hue to split strata by a given grouping variable
fig, ax = pa.alluvial(
    x = 'timepoint',
    stratum = 'module',
    alluvium = 'nodename',
    hue = 'signif',
    palette = 'tab20',
    data = data,
    stratum_gap = 2,
    stratum_width = 2,
    show_labels = True
)

fig.set_figwidth(10)
fig.set_figheight(5)
fig.tight_layout()

The color assignment for hue elements using string arguments for palette can be quite cumbersome. However, you can always pass a dictionary with the colors you want to use to palette instead of a string

tab20_colors = {
    '1_s': '#1F77B5',
    '1_ns': '#B0C6E8',
    '2_s': '#F07E21',
    '2_ns': '#F9BA79',
    '3_s': '#2AA137',
    '3_ns': '#9DCB88',
    '4_s': '#D62828',
    '4_ns': '#F29697'
}
colors = {
    f't{i}': tab20_colors for i in range(4)
}
fig, ax = pa.alluvial(
    x = 'timepoint',
    stratum = 'module',
    alluvium = 'nodename',
    hue = 'signif',
    palette = colors,
    data = data,
    stratum_gap = 2,
    stratum_width = 2,
    show_labels = True
)

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

pylluvial-1.1.1.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylluvial-1.1.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file pylluvial-1.1.1.tar.gz.

File metadata

  • Download URL: pylluvial-1.1.1.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for pylluvial-1.1.1.tar.gz
Algorithm Hash digest
SHA256 d077989ceff85fbe43296914d2f9a938d1bf291fdec74ad9c8b6a8400f86d791
MD5 694c5d9cd279065f18f865d51b819715
BLAKE2b-256 4246932b98666334fc91b37112e6894ef8d43ebaf0acd70d04a51e4f448632e3

See more details on using hashes here.

File details

Details for the file pylluvial-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: pylluvial-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for pylluvial-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82b8b25e311da1cb12843ce52f7225d2ca470e13c6e8ef24432b3e1921928471
MD5 ec6a2c3c30f8658664a3acba6d3dd9a8
BLAKE2b-256 0e675107bd736712be97afd24c0c2d03c1c840cf2048355588b05b1786186879

See more details on using hashes here.

Supported by

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