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 9228429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:19:18+00:00 2026-06-18T05:19:18+00:00

I want to create a plot, perhaps abandon it, then create another plot. import

  • 0

I want to create a plot, perhaps abandon it, then create another plot.

import matplotlib.pyplot as plt

plt.plot(xxx,yyy, ...)
if certain_conditions:
    return or otherwise get out of here
plt.show()

...sometime later, someplace far away...
# looking for incantation to make gone of the existing unshown plot
plt.plot(abc,def, ...)
plt.show()

These pieces of code are actually far apart, in different objects or modules, whatever. When the first plot is abandoned, the show() in the second chunk of code will show me more than what is desired; I just want to see abc vs. def plotted. I’m sure this is simple but I’m not finding it – what magic incantation do I want before starting the 2nd plot?

  • 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-18T05:19:19+00:00Added an answer on June 18, 2026 at 5:19 am

    There are a bunch of ways to do this, the ‘best’ is to move to using the OO interface instead of the state machine interface.

    If you don’t want to keep any figures you can do

    plt.close('all')
    

    which will close all existing figures. If you just want to close the current figure, you can do

    plt.close(plt.gca().number)
    

    If you do

    fig = plt.figure()
    

    you can create additional figures and close them with

    plt.close(fig.number)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to create a plot, press one button or another
I am plotting using Matplotlib in Python. I want create plot with grid, and
I want to create a pairs plot in R that has labels on the
I want to create a contour plot in MATLAB , as in the second
I want to create a function which plot on screen a set of figures
Ok, I can create a plot. But if I want the plot to be
I want to create stacked bar plot with absolute values for variables in the
I want to create a plot consisting of several subplots with shared x/y axes.
I want to create a plot which has listeners to every item which is
I want to use ggplot to create scatter plot where y scale to be

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.