Giter Club home page Giter Club logo

upsetty's Introduction

upsetty logo

Python Plotly Pandas

๐Ÿ“– Table of Contents

๐Ÿงฎ What is upsetty? Watermark

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.

Comparing Venn Diagram and UpSet Plot for 5 Interacting 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 are too verbose.

To that end, we offer upsetty as a lightweight, easy-to-use alternative for analyzing overlapping sets in Python.

๐Ÿคฉ Like this repository? Giving a โญ๏ธ really helps out!

๐Ÿš€ Quickstart

โฌ‡๏ธ Installation

pip install upsetty

โš™๏ธ Usage

from upsetty import Upset

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

import pandas as pd

# create sample data ({'class_name': [boolean indicators]})
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]
}

# convert sample data dict to pd.DataFrame
df = pd.DataFrame(data)

Then, simply pass the DataFrame to the generate_plot method to create a Plotly figure of an UpSet plot.

# create UpSet figure
upset = Upset.generate_plot(df)

# show the figure
upset.show()

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

Example UpSet Plot

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(
    
    # sample data
    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'
)

Example UpSet Plot with Custom Format

By default, the function expects a DataFrame with columns of all boolean values, indicating the presence of absence of a given class.

If you wish to compute set instersection based on some other value in your data, you can do so like this:

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

    # adding a column 'Value' of non-boolean numbers
    'Value': [1, 2, 3, 4, 5, 6, 7]
}

df = pd.DataFrame(data)

upset = Upset.generate_plot(df, 'Value')
upset.show()

The code above will compute the sum of values for each subset within the classes, as depicted below.

Example UpSet Plot based on 'Value'

๐Ÿ“Œ 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.

upsetty's People

Contributors

eskin22 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

upsetty's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.