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

[Bug]: Interactive mode - plot not displaying in interactive mode after callinginput() #25930

Open
@lostinnowhere314

Description

@lostinnowhere314

Bug summary

In interactive mode (plt.ion()), creating a plot and then immediately having a call toinput() causes the plot to not display until after the call toinput() has finished. Specifically, only an empty window is created initially, and it is not populated until after the call toinput() is finished.

Code for reproduction

frommatplotlibimportpyplotaspltx= [0,1]y= [2,3]plt.ion()# We expect the call to plt.plot() to create a figure since we're in interactive mode:plt.plot(x,y);input("Some input: ")# This line has the same effect as the above one:plt.plot(x,y);plt.ioff();plt.show(block=False);input("Some input: ")

Actual outcome

Matplotlib produces the following empty window:
image
Attempting to interact with this window tends to make Python unhappy.

The main terminal is pefectly responsive, and the input prompt can be typed in.
Only after theinput() call is complete will the plot actually display as intended, even with callingplt.ioff() andplt.show() afterwards.

Expected outcome

Ideally, the plot would update and display whileinput() is waiting for user input.

Additional information

Tested on several versions back; this issue also occurs on version 3.7.0, but not on versions 3.6.0 to 3.6.3.

Some additional info:

  • This issue happens in scripts and in the interactive terminal (ran in IPython 7.34.0), but not in Jupyter notebooks (tested the same snippet and it works the expected way).
  • If a plot is already displaying in interactive mode and this happens, the plot will just not update until afterinput() is finished
  • This also happens if the creation of the plot and the call toinput are more widely-separated; callingtime.sleep() in between does not help.
  • Turning off interactive mode before callinginput does not fix the issue, nor does callingplt.show() withblock=False (f.e. the lineplt.plot(x, y); plt.ioff(); plt.show(block=False); input("Some input: ") runs exactly the same)

Operating system

Windows 10

Matplotlib Version

3.7.1

Matplotlib Backend

TkAgg

Python version

3.9.12

Jupyter version

6.4.8

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    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