matplotlib / matplotlib/ipympl

make `%matplotlib widget` behave like `inline`?

Open
#171 11 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
1.7k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

I have a notebook in Jupyter Lab, so far using the default matplotlib backend, which in this context I believe is `inline`. When I have a sequence of plotting commands (`pyplot.plt` etc.), they combine into a figure that is shown after the respective code cell. Also, `@interact` works as expected.

I now wanted to zoom in, which `inline` does not support, so I issued `%matplotlib widget`. The figures are now zoomable alright, but I don't have that neat behavior where plotting code in one cell contributed to the following figure output cell, and doesn't modify anything else. And `@interact`, instead of producing new (versions of) a figure, now puts everything on top of each other.

From reading around I realize that this is the intended behavior. The thing is, I don't like it. So my question is: __Is there a way to make `widget` behave like `inline`?__

If there is not, is there a guide that tells me how to modify my code so that plot commands affect only the next output cell, and `@interact` updates instead of adds?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior in Jupyter Lab with `%matplotlib widget`, sequential plotting commands, and `@interact`, then compare it with the default inline backend. Determine whether the requested cell-scoped output and updating interaction can be supported; done means documenting a supported approach or clearly identifying the required behavior change.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter, jupyter-notebook
Domain
developer-experience, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.