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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:11:15+00:00 2026-05-24T08:11:15+00:00

I want to plot data, then create a new figure and plot data2, and

  • 0

I want to plot data, then create a new figure and plot data2, and finally come back to the original plot and plot data3, kinda like this:

import numpy as np
import matplotlib as plt

x = arange(5)
y = np.exp(5)
plt.figure()
plt.plot(x, y)

z = np.sin(x)
plt.figure()
plt.plot(x, z)

w = np.cos(x)
plt.figure("""first figure""") # Here's the part I need
plt.plot(x, w)

FYI How do I tell matplotlib that I am done with a plot? does something similar, but not quite! It doesn’t let me get access to that original 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-05-24T08:11:16+00:00Added an answer on May 24, 2026 at 8:11 am

    If you find yourself doing things like this regularly it may be worth investigating the object-oriented interface to matplotlib. In your case:

    import matplotlib.pyplot as plt
    import numpy as np
    
    x = np.arange(5)
    y = np.exp(x)
    fig1, ax1 = plt.subplots()
    ax1.plot(x, y)
    ax1.set_title("Axis 1 title")
    ax1.set_xlabel("X-label for axis 1")
    
    z = np.sin(x)
    fig2, (ax2, ax3) = plt.subplots(nrows=2, ncols=1) # two axes on figure
    ax2.plot(x, z)
    ax3.plot(x, -z)
    
    w = np.cos(x)
    ax1.plot(x, w) # can continue plotting on the first axis
    

    It is a little more verbose but it’s much clearer and easier to keep track of, especially with several figures each with multiple subplots.

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

Sidebar

Related Questions

I want to use core-plot for drawing line graph dynamically. data won't come at
I want to create a pairs plot in R that has labels on the
I want to plot data from different data frames with ggplot. However, I'm having
I want to plot multiple data sets on the same scatter plot: cases =
Rather than ask how to plot big data sets, I want to wrap plot
I want to plot stacked histograms in R; i.e. stack individual histograms in the
I want to remove the space between the axes of the plot and the
want to know why String behaves like value type while using ==. String s1
Want the function to sort the table by HP but if duplicate HPs then
I would like any advice on how to create and visualize a link map

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.