Skip to main content

Plot Hasse Diagram in Python

Project description

Hasse Diagram

This small package helps with plotting Hasse Diagrams and is very useful when presenting results for the MCDA methods.

Installation

pip install hasse-diagram

Example usage

import numpy as np
from hassediagram import plot_hasse

data = np.array([
    [0, 1, 1, 1, 1],
    [0, 0, 1, 0, 1],
    [0, 1, 0, 0, 1],
    [0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0]
])
labels = ["node a", "node b", "node c", "node d", "node e"]
plot_hasse(data, labels)

Result:

img.png

You can optionally turn off the transitive reduction and change the color of nodes and edges.

Testing

pytest --cov=src --cov-report=term-missing

This package is inspired by a similar one for R: hasseDiagram

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

hasse_diagram-1.0.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

hasse_diagram-1.0-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

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