Use Seaborn in Nitro apps
v0.2 of the Matplotlib plugin adds support for capturing the
pyplot context, which means the Seaborn package works out of the box.
If a figure is not provided to
matplotlib_box(), the global
matplotlib.pyplot instance is used as the source. This is useful when you're using something like Seaborn, which relies on matplotlib.pyplot, but not optimal when used inside a web app.
pyplot maintains references to the opened figures to make
show() work, but this will cause memory leaks unless the figures are properly closed.
Here's the plugin in action:
# Source: https://seaborn.pydata.org/examples/hexbin_marginals.html
rs = np.random.RandomState(11)
x = rs.gamma(2, size=1000)
y = -.5 * x + rs.normal(size=1000)
sns.jointplot(x=x, y=y, kind="hex", color="#4CB391")