|
From: Christophe B. <pro...@gm...> - 2014-03-13 14:33:34
|
Hello, I'm a little disappointed by the following test program coming from this post <http://stackoverflow.com/a/22380683/1054158>. What are the technical reasons that make fail the following code under Mac O$ ? Best regards. Christophe BAL ---- TEST --- from random import randint, choiceimport timeimport matplotlib.pyplot as pltimport matplotlib.patches as mpatches back_color = "black" colors = ['red', 'green', 'cyan', 'yellow'] width, height = 16, 16 fig, ax = plt.subplots() ax.set(xlim=[0, width], ylim=[0, height]) # Or use "ax.axis([x0,x1,y0,y1])" # Be sure to draw the canvas once before we start blitting. Otherwise# a) the renderer doesn't exist yet, and b) there's noting to blit onto fig.canvas.draw() def update(): x = randint(0, width - 1) y = randint(0, height - 1) rect = mpatches.Rectangle( (x, y), 1, 1, facecolor = choice(colors), edgecolor = back_color ) ax.add_artist(rect) start = time.time() ax.draw_artist(rect) fig.canvas.blit(ax.bbox) print("draw >>>", time.time() - start) timer = fig.canvas.new_timer(interval=1) timer.add_callback(update) timer.start() plt.show() |