An upset plot creation package using Plotly
Project description
Created by Blake McBride
🧐 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
pip install upsetty
🛠 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.