Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8233509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:09:13+00:00 2026-06-07T18:09:13+00:00

I am experiencing some problems with matplotlib…. I can’t open 2 windows at once

  • 0

I am experiencing some problems with matplotlib…. I can’t open 2 windows at once to display a image with show(), it seems that the script stops at the line i use show and doesn’t continue unless I close the display manually. Is there a way to close the figure window within the scrip?

the following code doesn’t run as I want:

import matplotlib.pyplot as plt
from time import sleep
from scipy import eye

plt.imshow(eye(3))
plt.show()
sleep(1)
plt.close()
plt.imshow(eye(2))
plt.show()

I expected the first window to close after 1 second and then opening the second one, but the window doesn’t close until I close it myself. Am I doing something wrong, or is it the way it is supposed to be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:09:15+00:00Added an answer on June 7, 2026 at 6:09 pm

    plt.show() is a blocking function.

    Essentially, if you want two windows to open at once, you need to create two figures, and then use plt.show() at the end to display them. In fact, a general rule of thumb is that you set up your plots, and plt.show() is the very last thing you do.

    So in your case:

    fig1 = plt.figure(figsize=plt.figaspect(0.75))
    ax1 = fig1.add_subplot(1, 1, 1)
    im1, = plt.imshow(eye(3))
    
    fig2 = plt.figure(figsize=plt.figaspect(0.75))
    ax2 = fig2.add_subplot(1, 1, 1)
    im2, = plt.imshow(eye(2))
    
    plt.show()
    

    You can switch between the plots using axes(ax2).

    I put together a comprehensive example demonstrating why the plot function is blocking and how it can be used in an answer to another question: https://stackoverflow.com/a/11141305/1427975.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm debugging a service that's experiencing some problems on start-up. To aid me in
I am experiencing some problems while working with ComboBox. The display member for my
boost.org is experiencing some problems with documentation - it just wouldnt open. Is there
I'm experiencing some problems getting an Open Graph implementation working. As far as I
I'm currently experiencing some problems with my server. I have a pool which is
I'm experiencing some problems with breaking my code to reusable parts using templates and
I'm experiencing some problems while trying to read a binary file in C. This
I am experiencing some performance problems when creating a very simple Python HTTP server.
I am experiencing some problems with a google chrome extension I have made. I've
Okay i'm new to asp mvc2 and i'm experiencing some problems with the htmlhelper

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.