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

  • SEARCH
  • Home
  • 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 8314043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:41:27+00:00 2026-06-08T20:41:27+00:00

I’ve done a search on SO but haven’t quite found the right solution to

  • 0

I’ve done a search on SO but haven’t quite found the right “solution” to my problem. I am running a loop on some data that I wish to plot. At each step of the loop — I plot the figure with plt.show(). However, since this is a blocking function, i am stuck until I manually close the window and then the loop continues and the next plot shows up.

What I would like to do is be able to bind a key press event to close the figure and continue the loop (rather than using the mouse to “X” out of the figure).

If this is not possible, I would like to set a timer to close the figure and continue the loop.

All my issues seem to deal with the fact that plt.show() is blocking everything else — any way around this?

Some notes on my plots: They use the same axes, but contain a scatter plot, fill boxes, and annotations — which are always changing.

Thanks!

  • 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-08T20:41:28+00:00Added an answer on June 8, 2026 at 8:41 pm

    Try using ion from matplotlib.pyplot:

    import matplotlib.pyplot as pp
    pp.ion()
    fig = pp.figure()
    

    More info about ion and interactive vs non-interactive usage here

    Alternatively if you want to go with the button press approach assign a callback

    def moveon(event):
        pp.close()
    
    cid = fig.canvas.mpl_connect('key_press_event', moveon)
    pp.show()
    

    An event timer is more tricky because the show command is blocking, so it would probably have to involve threading.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I am currently running into a problem where an element is coming back from
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.