Note
Go to the end to download the full example code
Upset Plot#
IMDB Top 1000 Movies

/home/docs/checkouts/readthedocs.org/user_builds/marsilea/envs/v0.3.2/lib/python3.10/site-packages/marsilea/upset.py:328: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
df = pd.DataFrame(sets).fillna(False).astype(int)
/home/docs/checkouts/readthedocs.org/user_builds/marsilea/envs/v0.3.2/lib/python3.10/site-packages/marsilea/plotter/_seaborn.py:108: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plotter(data=pdata, orient=orient, ax=ax, **options)
from matplotlib import pyplot as plt
import marsilea as ma
from marsilea.upset import UpsetData, Upset
imdb = ma.load_data("imdb")
items_attrs = (imdb[['Title', 'Year', 'Runtime (Minutes)', 'Rating',
'Votes', 'Revenue (Millions)', 'Metascore']]
.set_index('Title'))
upset_data = UpsetData.from_memberships(imdb.Genre.str.split(','),
items_names=imdb['Title'],
items_attrs=items_attrs)
us = Upset(upset_data, min_cardinality=15)
us.highlight_subsets(min_cardinality=48, facecolor="#D0104C",
label="Larger than 48")
us.highlight_subsets(min_cardinality=32, edgecolor="green", edgewidth=1.5,
label="Larger than 32")
us.add_items_attr("bottom", "Revenue (Millions)", "strip", pad=.2, size=.5,
plot_kws=dict(palette="dark:#24936E", size=1.2, label=""))
us.add_title(bottom="Revenue (Millions)", fontsize=10)
us.add_items_attr("top", "Rating", "box",
pad=.2,
plot_kws=dict(color="orange", linewidth=1, fliersize=1))
us.add_title(top="Rating", fontsize=10)
us.add_legends(box_padding=0)
us.set_margin(.3)
us.render()
plt.show()
Total running time of the script: (0 minutes 2.695 seconds)