我正在尝试使用gtk窗口中的drawow绘制动态图形。例如,这一个
from pylab import arange, plt
import numpy as np
from drawnow import drawnow
plt.ion() # enable interactivity
fig=plt.figure() # make a figure
def makeFig():
plt.scatter(x,y) # I think you meant this
x=list()
y=list()
for i in arange(1000):
temp_y=np.random.random()
x.append(i)
y.append(temp_y) # or any arbitrary update to your figure's data
i+=1
drawnow(makeFig)
我已经看到使用matplotlib的静态数字是可行的:
import gtk
from matplotlib.figure import Figure
from numpy import arange, sin, pi
# uncomment to select /GTK/GTKAgg/GTKCairo
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
win = gtk.Window()
win.connect("destroy", lambda x: gtk.main_quit())
win.set_default_size(400, 300)
win.set_title("Embedding in GTK")
f = Figure(figsize=(5, 4), dpi=100)
a = f.add_subplot(111)
t = arange(0.0, 3.0, 0.01)
s = sin(2*pi*t)
a.plot(t, s)
canvas = FigureCanvas(f) # a gtk.DrawingArea
win.add(canvas)
win.show_all()
gtk.main()
但问题是我想要一个充满活力的人物。我不知道怎么能这样做。请帮忙