[Matplotlib-users] Using Matplotlib nbagg for _repr_html_ for notebooks
jni.soma at gmail.com
Wed Nov 7 19:24:45 EST 2018
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:
> Something like:
> 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 current master)
> 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()
> fig.savefig(output, format='png')
> 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?
>> .. : https://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display
>> Matplotlib-users mailing list
>> Matplotlib-users at python.org
> Thomas Caswell
> tcaswell at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Matplotlib-users