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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:01:57+00:00 2026-06-05T07:01:57+00:00

I am new to matplotlib. I have a list of x-y coordinates that I

  • 0

I am new to matplotlib. I have a list of x-y coordinates that I update in python and want to animate using matplotlib’s pyplot. I want to specify the x-range and y-range in advance. Below is my current code:

import matplotlib.pyplot as plt
x=[1,2,3,4]
y=[5,6,7,8]
for t in range(100):
    #lists x and y get updated here
    #...
plt.plot(x, y, marker='o', linestyle='None')
plt.show()

As you can see, I use plt.plot() and plt.show() at the end of my iteration loop to plot only the final coordinates. But I want to put this step inside the loop and plot at every iteration with a specified pause time so that I have an animation as the loop runs.

Just moving that statement inside the loop or tweaks thereabout aren’t working.
I want to keep it very simple though, and don’t want to use matplotlib.animation. Is there some simple method without using many more modules and libraries (only stuff like plt.pause() and perhaps only a bit more) that will let me do what I want?

I looked at many places online, and the problem I face with most methods there is that I am using python(x,y) (that’s python version 2.7) on Windows for this, and animations using too complicated modules and libraries are crashing here.

However, I am able to run simple stuff like this example on the matplotlib site, which is close to what I want, but not quite. So perhaps the best thing will be a modification of this example that works for my case of 2D data (that example is for a 1D row). But any other suggestion is welcome.

  • 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-05T07:02:01+00:00Added an answer on June 5, 2026 at 7:02 am

    This is adapted from the animation demo:

    import matplotlib.pyplot as plt 
    import numpy as np
    
    fig, ax = plt.subplots()
    
    x = [1, 2, 3, 4]
    y = [5, 6, 7, 8]
    
    for t in range(10):
        if t == 0:
            points, = ax.plot(x, y, marker='o', linestyle='None')
            ax.set_xlim(0, 10) 
            ax.set_ylim(0, 10) 
        else:
            new_x = np.random.randint(10, size=5)
            new_y = np.random.randint(10, size=5)
            points.set_data(new_x, new_y)
        plt.pause(0.5)
    

    While this is simple the docstring say that it is slow.

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

Sidebar

Related Questions

I have a list of handles to points that have been plotted using matplotlib.pyplot
I'm plotting a bunch of UTM coordinates using a matplotlib.pyplot.scatter. I also have a
I have a matplotlib figure that I want to be able to switch between
I'm rather new to both python/matplotlib and using it through the ipython notebook. I'm
I am new to Matplotlib and Python. I mostly use Matlab. Currently, I am
new on ruby and using windows xp and rails 3, i want to send
I'm new to python and have been trying to figure this out all day.
My problem is: I have Matplotlib figure in PyGTK application, that is constatly updated
I am very new to Python and I have been trying to detect missing
I am new to using matplotlib. I am trying to create a 2D grid,

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.