Matplotlib animation zu langsam ( ~3 fps )

Muss ich animieren, um die Daten so wie Sie kommen mit einem 2D-histogram2d ( vielleicht später 3D-aber als ich höre, mayavi ist besser für die ).

Hier der code:

import numpy as np
import numpy.random
import matplotlib.pyplot as plt
import time, matplotlib


plt.ion()

# Generate some test data
x = np.random.randn(50)
y = np.random.randn(50)

heatmap, xedges, yedges = np.histogram2d(x, y, bins=5)
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]

# start counting for FPS
tstart = time.time()

for i in range(10):

    x = np.random.randn(50)
    y = np.random.randn(50)

    heatmap, xedges, yedges = np.histogram2d(x, y, bins=5)

    plt.clf()
    plt.imshow(heatmap, extent=extent)
    plt.draw()

# calculate and print FPS
print 'FPS:' , 20/(time.time()-tstart)

Gibt es 3 fps, zu langsam offenbar. Ist es die Verwendung von numpy.random in jeder iteration? Sollte ich blit? Wenn ja, wie?

Haben die docs einige schöne Beispiele, aber für mich, die ich brauche, um zu verstehen, was alles funktioniert.

InformationsquelleAutor Kevin | 2012-06-08
Schreibe einen Kommentar