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

Appearance settings

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

Copy link
Copy link
Open
@lostinnowhere314

Description

@lostinnowhere314
Issue body actions

Bug summary

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

Code for reproduction

from matplotlib import pyplot as plt
x = [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 the input() call is complete will the plot actually display as intended, even with calling plt.ioff() and plt.show() afterwards.

Expected outcome

Ideally, the plot would update and display while input() 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 after input() is finished
  • This also happens if the creation of the plot and the call to input are more widely-separated; calling time.sleep() in between does not help.
  • Turning off interactive mode before calling input does not fix the issue, nor does calling plt.show() with block=False (f.e. the line plt.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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.