Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add _repr_html_ for inline backend to eliminate need for %matplotlib inline #16782

Closed as not planned
Labels
status: inactiveMarked by the “Stale” Github Action
@tdpetrou

Description

@tdpetrou

When launching a jupyter notebook, the environment variableMPLBACKEND is set to inline, but figures will still not be displayed in the output unless%matplotlib inline orimport matplotlib.pyplot is run. Both of these commands hook IPython to a function that gets triggered whenever a Figure is the output from a cell. This function is responsible for printing the figure to the screen.

Screen Shot 2020-03-15 at 9 32 10 PM

Proposed solution:

A_repr_html_ method exists for figures, but is only implemented for webagg backends. Something like the following could be added to_repr_html_.

ifrcParams['backend']=='module://ipykernel.pylab.backend_inline':fromioimportBytesIOfrombase64importb64encodepng_bytes=BytesIO()self.canvas.print_figure(png_bytes,format='png')s=png_bytes.getvalue()s1=b64encode(s).decode()returnf'<img src="data:image/png;base64,{s1}"/>'

This is@tacaswell's idea. I previously created an issue with IPython -ipython/ipython#12190 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: inactiveMarked by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp