diff --git a/upsetplot/plotting.py b/upsetplot/plotting.py index 9cbf977..c677f32 100644 --- a/upsetplot/plotting.py +++ b/upsetplot/plotting.py @@ -145,6 +145,7 @@ class UpSet: of the intersection. When a string, this formats the number. For example, '%d' is equivalent to True. """ + _default_figsize = (10, 6) def __init__(self, data, orientation='horizontal', sort_by='degree', sort_sets_by='cardinality', facecolor='black', @@ -366,7 +367,7 @@ def plot(self, fig=None): Keys are 'matrix', 'intersections', 'totals', 'shading' """ if fig is None: - fig = plt.figure(figsize=(10, 6)) + fig = plt.figure(figsize=self._default_figsize) specs = self.make_grid(fig) shading_ax = fig.add_subplot(specs['shading']) self.plot_shading(shading_ax) @@ -384,6 +385,11 @@ def plot(self, fig=None): 'shading': shading_ax, 'totals': totals_ax} + def _repr_html_(self): + fig = plt.figure(figsize=self._default_figsize) + self.plot(fig=fig) + return fig._repr_html_() + def plot(data, fig=None, **kwargs): """Make an UpSet plot of data on fig