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

  • Home
  • SEARCH
  • 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 9105453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:06:41+00:00 2026-06-17T02:06:41+00:00

I am having a major setback on this question on a while now… import

  • 0

I am having a major setback on this question on a while now…

import numpy as np
import matplotlib.pyplot as plt

plt.ion()
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.set_title("linear realtime")
line, = ax.plot([],[])

i = 0 
while ( i < 1000 ):
        #EDIT:
        # this is just sample data, but I would eventually like to set data 
        # where it can be floating numbers...
        line.set_data(i,i)             
        fig.canvas.draw()
        i += 1

I am trying to draw a linear line in real time but I am unable to come up with the result. Thanks in advance. So far, I have a figure coming up but nothing is being drawn on the canvas.

EDIT:

Interesting…. I am now able to plot the dots on the line but now, I am unable to show their connectivity between each point… I also noticed that if you removed ko- when it is being plotted… nothing appears, does anybody know why?

import numpy as n
import pylab as p
import time

x=0
y=0 
p.ion()
fig=p.figure(1)
ax=fig.add_subplot(111)
ax.set_xlim(0,10)
ax.set_ylim(0,10)
line,=ax.plot(x,y,'ko-')
for i in range(10):
    x = i
    y = i
    line.set_data(x,y)
    p.draw()
  • 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-17T02:06:43+00:00Added an answer on June 17, 2026 at 2:06 am

    add a p.pause(.001) in your loop. You need to allow time for the gui event loops to trigger and update the display.

    This is related to issue #1646.

    The other issue you have is that when you do set_data it replaces the data that is plotted with the x and y passed in, not append to the data that is already there. (To see this clearly use p.pause(1)) When you remove 'ko-', which defaults to no marker with a line connecting points you are plotting a single point, hence nothing shows up.

    I think you intended to write this:

    x=0
    y=0 
    
    fig=plt.figure(1)
    ax=fig.add_subplot(111)
    ax.set_xlim(0,10)
    ax.set_ylim(0,10)
    line,=ax.plot(x,y,'ko-')
    for i in range(10):
        x = np.concatenate((line.get_xdata(),[i]))
        y = np.concatenate((line.get_ydata(),[i]))
        line.set_data(x,y)
        plt.pause(1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sure this question has been answered somewhere but I'm having major problems
I'm having a major issue which has been bugging me for a while now.
Having used storyboards for a while now I have found them extremely useful however,
Ok, Im having major problems trying to expose this enumerated type over my webservice.
I am having major issues with a ScrollPane component in Papervision3D. This issue has
I'm having a major problem trying to get this Galaxy Nexus showing up in
Ok ive been having this major problem with my site. Whats going on is
I upgraded our JQuery-UI from 1.8rc3 to 1.8.6 and now I am having major
Been having major issues trying to solve this issue, I'll be happy to give
I'm having a major problem with this school assignment; lucky I started it early

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.