1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Removing previously plotted points on scatter plot; python

  1. Nov 12, 2017 #1
    1. The problem statement, all variables and given/known data
    I'm plotting moving particles and I need a way to refresh the graph space with every loop. Meaning I want the points to NOT leave a trail of other points behind them . Basically I want to get rid of the old points as I plot new ones.

    2. Relevant equations
    N\A

    3. The attempt at a solution
    The code for plotting that is being used :
    Code (Python):

    while True:

        plt.ion()
        plt.show()

        x,y = 0,0

        for i in range(n_particles):
            x = particle_pos[i,0]
            y = particle_pos[i,1]
            plt.scatter(x,y, color='green')
            plt.pause(0.001)
            plt.xlim(0 , L)
            plt.ylim(0 , L)
     
    Mentor edit - added code tags.
     
    Last edited by a moderator: Nov 12, 2017
  2. jcsd
  3. Nov 12, 2017 #2

    jim mcnamara

    User Avatar

    Staff: Mentor

  4. Nov 13, 2017 #3

    donpacino

    User Avatar
    Gold Member

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Removing previously plotted points on scatter plot; python
  1. Python Help in Plotting (Replies: 14)

Loading...