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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:14:50+00:00 2026-05-25T03:14:50+00:00

Using pyplot, I’ve created a figure and plotted a number of randomly scattered (x,y)

  • 0

Using pyplot, I’ve created a figure and plotted a number of randomly scattered (x,y) points. I then want to connect some subset of these points with line segments. After the user presses a key, my program needs to then erase the previously drawn set of line segments (leaving the original points in place) and then draw new segments between another set of points.

My problem is that I don’t know how to erase the previous line segments. I tried re-plotting them in the background color (which is white) but this leaves a residue of non-white pixels where the line was. I can’t find any examples in the on-line documentation that does this. Is it possible and, if so, how?

  • 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-25T03:14:50+00:00Added an answer on May 25, 2026 at 3:14 am

    Scipy has a tutorial for deleting a line from an axes. I use this in the following example, which I think emulates what you are trying to do:

    import matplotlib.pyplot as plt
    import numpy as np
    
    x = np.arange(10)
    np.random.seed(101)
    y = np.random.rand(10)
    
    small = [i for i in range(len(x)) if y[i] < .5 ]
    big = [i for i in range(len(x)) if y[i] > .5 ]
    
    fig = plt.figure()
    ax = fig.add_subplot(111)
    
    ax.scatter(x,y)
    # user wants to plot lines connecting big values (>.5)
    ax.plot(x[big],y[big])
    
    #plt.show()
    # now user wants to delete the first (and only) line
    del ax.lines[0]
    
    # so that they can plot a line only showing small values
    ax.plot(x[small],y[small])
    
    plt.show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using matplotlib.pyplot.scatter to draw some simple scatter plot. However, something wrong appears
I created a 3D plot using matplotlib as this: fig = pylab.figure() ax =
I want to calculate the magnetic field of a wire using biot-savart-law. Some people
I am encountering some strange behavior with using the matplotlib.pyplot ginput() function to store
I am making a plot using matplotlib.pyplot imported as PL: FIG = PL.figure(figsize=(12,8), dpi=150)
I'm trying to create an image using matplotlib.pyplot.imshow() . However, when I run the
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
I am currently using matplotlib.pyplot to create graphs and would like to have the
Hi probably quite a simple question but.. When plotting a graph using matplotlib.pyplot my
I'm using matplotlib at the moment to try and visualise some data I am

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.