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

Switching to inline backend closes GUI windows #15913

Closed
Milestone
@flutefreak7

Description

@flutefreak7

Bug report

Bug summary

When a plot is made with theqt5 backend on and then the backend is changed toinline, the active plot window(s) are closed. This makes it very difficult to switch cleanly between backends within a notebook. The two mediocre workarounds I can see are:

  • always specify the backend before plotting (since you can't automatically "switch back")
  • useplt.show(block=True) and switch back toinline after the user is done with the GUI figure. This has the downside of locking the Notebook execution while the figure is live.

Code for reproduction

The linked gist shows what I'd like to accomplish which is a context manager that enables matplotlib plotting in a GUI window from within a Notebook that is otherwise using theinline backend. Basically I want the notebook to use inline (for a variety of reasons), but I occasionally wish I could interact with the data in a separate figure.
https://gist.github.com/flutefreak7/65d824358122360911e2d4c43085007a

As a side note, easy switching betweeninline andnotebook/widget backends would also scratch part of this itch, but the interactive notebook backends still don't enable full screen usage or easily throwing a plot on another monitor.ipyvolume has full screen figured out, so that seems doable.

Here's the context manager I wish worked:

# Paste your code here@contextmanagerdefwindow(block=False):%matplotlibqt5plt.ioff()yieldplt.show()# The switch back to inline closes the qt5 plotplt.ion()%matplotlibinlinewithwindow():plt.plot([1,3,2])

Actual outcome

The outcome of the above code is that a plot window flashes into existence for a split second, then is closed when the%matplotlib inline call is processed.

Expected outcome

It would be great if plots created with the qt5 backend could stay visible while other plots with the inline backend were also being created. If use%gui qt (to establish a reliable event loop) and create a bunch of Qt windows by other means, they live concurrently with the Notebook as long as the kernel is alive. I'd like matplotlib GUI figures to be able to live on regardless of the current backend.

Matplotlib version

  • Operating system:
  • Matplotlib version: 3.1.1
  • Matplotlib backend (print(matplotlib.get_backend())):inline andqt5agg
  • Python version: 3.7.3
  • Jupyter version (if applicable):
jupyter                           1.0.0jupyter-client                    5.3.4jupyter-console                   6.0.0jupyter-contrib-core              0.3.3jupyter-contrib-nbextensions      0.5.1jupyter-core                      4.6.0jupyter-highlight-selected-word   0.2.0jupyter-latex-envs                1.4.6jupyter-nbextensions-configurator 0.4.1jupyterlab                        1.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp