Skip to main content

An upset plot creation package using Plotly

Project description

Created by Blake McBride



Python Plotly Pandas

🧐 What is this project?

Python package for creating UpSet plots using Plotly.

What's an UpSet Plot?

An UpSet plot is a diagram used to quantitatively visualize sets and their interactions. They are particularly useful visuals for determining the overlap between different groups, as an alternative to Venn or Euler diagrams, which can become cluttered and hard to read with more than a few sets.

Why create upsetty?

Currently, the number of tools to create UpSet plots is very limited. Indeed, many of the previous packages for creating these plots have been deprecated or verbose. To that end, we offer upsetty as a lightweight, easy-to-use alternative for analyzing overlapping sets in Python.

🚀 Installation

[!NOTE]
This package is currently unavailable on PyPi. We're working on getting the project set up there so that you can use pip for installation in the future. For now, the only way to use this is via cloning the repo to your local.

Clone this Repository

The instructions below are adapted from GitHub's documentation on cloning repositories; for more information, please refer to the docs.

Show instructions
  1. Navigate to the main page of the repository.

  2. Above the list of files, click <> Code.

  3. Copy the URL for the repository.

    • To clone the repository using HTTPS, under "HTTPS", click .
  4. Open Git Bash.

  5. Change the current working directory to the location where you want the cloned repository. e.g.

    cd path/to/folder
    
  6. Type git clone, and then paste the URL you copied earlier, e.g.

    git clone https://github.com/eskin22/upsetty
    
  7. Press Enter to create your local clone.

🛠 Usage

Once you've installed the package, you can simply import the Upset class like so:

from upset import Upset

Then, to create an UpSet plot, we structure the data like this:

import pandas as pd

data = {
    'Class A': [True, True, True, False, False, True],
    'Class B': [True, True, True, True, True, False],
    'Class C': [False, False, False, True, True, True]
}

df = pd.DataFrame(data)

After creating your sample data, you can simply pass the DataFrame to the generate_plot method to create a plotly figure of an UpSet plot.

upset = Upset.generate_plot(df)
upset.show()

Using the sample data provided above, the output is pictured below:

[!NOTE]
If you're having trouble getting the output pictured above, you can run the demo script located at upsetty/demo.py.

You can also change the colors and sizing for various aspects of the plot by passing additional parameters to the generate_plot function like so:

upset = Upset.generate_plot(
    df,
    # change category colors to a light blue, green, and yellow
    categories_colors=['#3987CA', '#FFC300', '#39CA41'],

    # change the category label color to a dark black
    categorylabel_color='#2F2F2F',

    # change the bar intersect color to a soft black
    bar_intersect_color='#454545',

    # change the marker line color to a soft black
    markerline_color='#454545'
)

📌 Future Plans

Auto-adjusting margins for variable class labels

Currently, the upsetty works best with 3-4 class labels. More or less than that causes the class labels to be misaligned. Future improvements will add capabilities for auto-adjusting the margins based on the number of class labels contained in the visual.

Intersection highlighting

The ability to highlight specific intersections would give the user a way to focus their visual on specific set interactions as opposed to the basic highlighting.

Intersection count makeup

The ability to show the makeups of the different classes in a set intersection count.

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

upsetty-0.1.0.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

upsetty-0.1.0-py3-none-any.whl (3.2 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