marsilea.upset.Upset#
- class marsilea.upset.Upset(data, orient='h', sort_sets=None, sets_order=None, sets_color=None, sort_subsets='cardinality', min_degree=None, max_degree=None, min_cardinality=None, max_cardinality=None, color='.1', shading=0.3, radius=50, linewidth=1.5, grid_background=0.1, fontsize=None, add_intersections=True, add_sets_size=True, add_labels=True, width=None, height=None)#
Bases:
WhiteBoardUpset Plot
- Parameters:
- data
UpsetData Upset data
- orientstr
The orientation of the Upset plot
- sets_orderarray of str
The order of sets
- sets_colorarray of color
The color for each set, this will also change the bar color in set size
- sort_sets{‘ascending’, ‘descending’}
The sorting order of sets
- sort_subsets{‘cardinality’, ‘degree’}
How to sort the subset, ‘size’ will sort by intersection size, ‘degree’ will sort by the number of intersected sets.
- min_degree, max_degreeint
Select a fraction of subset to render by degree
- min_cardinality, max_cardinalityint
Select a fraction of subset to render by cardinality
- colorcolor
The main color to use
- shadingfloat
The value to dilute the main color
- radiusfloat
The size of the dot
- linewidthfloat
The width of lines that connect the dots
- grid_backgroundfloat
The value to dilute the main color for background
- fontsizeint
Set the fontsize for the plot
- add_intersectionsbool, str, default: True
Whether or which side to add the intersection size.
- add_sets_sizebool, str, default: True
Whether or which side to add the sets size.
- add_labelsbool, str, default: True
Whether or which side to add the label.
- widthfloat
- heightfloat
- ratiofloat
- data
Examples
>>> from marsilea.upset import UpsetData, Upset >>> data = UpsetData.from_sets([[1, 2, 3, 4], >>> [3, 4, 5, 6], >>> [1, 6, 10, 11]]) >>> Upset(data).render()
- add_intersections(side, pad=0.1, size=1.0)#
- add_items_attr(side, attr_name, plot, name=None, pad=0.1, size=None, plot_kws=None)#
Add a plot for the items attribute
- Parameters:
- sidestr
The side to add the plot, can be ‘left’, ‘right’, ‘top’, ‘bottom’
- attr_namestr
The name of the attribute
- plotstr
The type of plot, can be ‘bar’, ‘box’, ‘boxen’, ‘violin’, ‘point’, ‘strip’, ‘swarm’, ‘stack_bar’, ‘number’
- namestr, optional
The name of the plot
- padfloat, optional
The padding between the plot and the axis
- sizefloat, optional
The size of the plot
- plot_kwsdict, optional
The keyword arguments for the plot
- add_sets_attr(side, attr_name, plot, name=None, pad=0.1, size=None, plot_kws=None)#
Add a plot for the sets attribute
- Parameters:
- sidestr
The side to add the plot, can be ‘left’, ‘right’, ‘top’, ‘bottom’
- attr_namestr
The name of the attribute
- plotstr
The type of plot, can be ‘bar’, ‘box’, ‘boxen’, ‘violin’, ‘point’, ‘strip’, ‘swarm’, ‘stack_bar’, ‘number’
- namestr, optional
The name of the plot
- padfloat, optional
The padding between the plot and the axis
- sizefloat, optional
The size of the plot
- plot_kwsdict, optional
The keyword arguments for the plot
- add_sets_label(side, pad=0.1, size=None, **props)#
- add_sets_size(side, pad=0.1, size=1.0, **props)#
- get_data()#
- get_intersection_ax()#
- get_sets_label_ax()#
- get_sets_size_ax()#
- highlight_subsets(present=None, absent=None, min_cardinality=None, max_cardinality=None, min_degree=None, max_degree=None, facecolor=None, edgecolor=None, edgewidth=None, hatch=None, edgestyle=None, label=None)#
Highlight a subset of the data.
Notice that the color of hatch is determined by the edgecolor.
- Parameters:
- present
The sets that present in the subset
- absent
The sets that absent in the subset
- min_cardinality
The minimum cardinality of the subset
- max_cardinality
The maximum cardinality of the subset
- min_degree
The minimum degree of the subset
- max_degree
The maximum degree of the subset
- facecolor
The facecolor to decorate the subset
- edgecolor
The color of the edge line
- edgewidth
The edgewidth of the edge line
- hatch
The fill pattern
- edgestyle
The style of edge line
- label
The label for the highlighting
- classmethod update_attr_plotter(attr_plotter)#
Update the global upset plot for attr plotter