Skip to main content

A generic and colored Upset Plot generator using Plotly

Project description

Upset Plot Package

A generic Python package for generating Upset Plots using Plotly. This package allows you to visualize intersections of sets and categories, supporting both standard and colored variations.

Installation

You can install this package locally:

pip install upset_plot_plotly

Usage

Usage

import pandas as pd
from upset_plot import plot

# 1. Prepare Data
df = pd.DataFrame({
    'Category A': [True, True, False, True],
    'Category B': [True, False, True, True],
    'Category C': [False, True, True, False]
})

categories_dict = {
    'Category A': df['Category A'],
    'Category B': df['Category B'],
    'Category C': df['Category C']
}

# 2. Plot
fig = plot(df, categories_dict, title="My Upset Plot")
fig.show()

Colored Usage

For scenarios where you want to color-code specific elements (e.g., based on source or type):

from upset_plot import ColoredUpsetPlotGenerator

# Define colors for each category
category_colors = {
    'Category A': '#D32F2F',  # Red
    'Category B': '#1976D2',  # Blue
    'Category C': 'purple'
}

upset_gen = ColoredUpsetPlotGenerator(
    df, 
    categories_dict, 
    category_colors=category_colors
)
upset_gen.compute_combinations()

fig = upset_gen.plot(title="Colored Upset Plot")
fig.show()

Features

  • Simple Functional API: Generate complex Upset plots with a single function call plot().
  • Interactive Visualizations: Built on top of Plotly, allowing for zoom, hover, and detailed data inspection.
  • Automatic Set Size Calculation: Automatically computes set sizes and intersection counts from your DataFrame.
  • Customizable Appearance:
    • Bar Colors: Customize the color of the intersection bars.
    • Highlighting: Use active_color and inactive_color to distinguish between included and excluded sets in the matrix.
    • Connection Lines: Style the lines connecting the set matrix points.
  • Flexible Filtering:
    • Filter combinations by a minimum number of intersecting sets (min_sets).
    • Display specific ranges of combinations (combinations_range).
  • Colored Upset Plots: Support for advanced coloring logic (e.g., coloring matrix dots based on specific categories) using category_colors.
  • Responsive Layout: Auto-calculated heights with options to override for perfect integration into dashboards.
  • Framework Agnostic: Works seamlessly with any Python environment (Jupyter, Streamlit, etc.) that supports Plotly.

Dependencies

  • pandas
  • plotly

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

upset_plot_plotly-0.2.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file upset_plot_plotly-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for upset_plot_plotly-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 20d40c271b4beaa495b309932f62dab4c6aeca35f644e1a68bfd4295211e1899
MD5 8f1256cdbd7144752a0817d40b53f464
BLAKE2b-256 cc631969298e13503c99abb67e172712c2a1b8687f900543dfff6dcc1652eb5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for upset_plot_plotly-0.2.2-py3-none-any.whl:

Publisher: publish.yml on prabinrajkp/upset_plot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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