Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: 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

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

    while True:


        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.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


    User Avatar
    Gold Member

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted