Skip to content

Commit

Permalink
Implement _repr_html. Fixes #36
Browse files Browse the repository at this point in the history
  • Loading branch information
jnothman committed Feb 24, 2019
1 parent f83b941 commit e470d9f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion upsetplot/plotting.py
Expand Up @@ -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',
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit e470d9f

Please sign in to comment.