semvec/pypi-packages huggingface dataset:
upset-plot-plotly 0.2.2
A generic and colored Upset Plot generator using Plotly
Requires Python: >=3.6

# 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:
```bash
pip install upset_plot_plotly
```

## Usage

### Usage

```python
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):

```python
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