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()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…