My question is, would it be possible for the html to contain the
interactive MPL figure, as returned by the notebook backend? There's also
But yes, this is already great, I can use this for _repr_png_.
I'm targeting 3.0+ so "new enough matplotlib" shouldn't be an issue. =)
On Thu, Nov 8, 2018, at 11:16 AM, Thomas Caswell wrote:
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvas
fig = Figure()
canvas = FigureCanvas(fig) # this step will be optional in mpl 3.1 (and
ax = fig.subplots() # assuming new enough matplotlib
or one of the other backends. If you are doing this for a htmlrepr you
likely want to also do
output = BytesIO()
to get the image as a buffer you can inject into the repr (or SVG?)
Hope that helps!
On Wed, Nov 7, 2018 at 4:38 PM Juan Nunez-Iglesias <jni.soma at gmail.com> > wrote:
I'm working on a class to which I would like to add a _repr_html_ 
method for display in Jupyter notebooks. Is there a way to generate a
matplotlib notebook backend view "offline" (not using pyplot, since that
will behave differently depending on the currently active backend), and
then return the corresponding html?
Matplotlib-users mailing list
Matplotlib-users at python.org
tcaswell at gmail.com