I have appended some code which draws a varying pcolor plot in a Tkinter
window. The plot shows two 5x5 white rings which shrink to 3x3 and then
1x3, then cycles through this repeatedly.
Unfortunately, it slows down with each cycle!!!
Are we doing something wrong? Or can we work around the problem somehow?
(By the way, I did not write the code, though I cleaned up some portions
of it. I realize the data generation can be cleaned up, but it's not
slowing things down).
P.S. At risk of distracting from the main problem: I am not entirely
sure I'm commanding a redraw in the correct fashion. I'm fuzzy on the
difference between show and plot. Using canvas.show() and canvas.plot()
both seem to work. Just calling plot() doesn't. Any hints on this or
pointers to documentation would be appreciated.
Also, is pcolor documented anywhere?
----- the code -----
import Tkinter as Tk
from matplotlib.pylab import *
import matplotlib.numerix as num
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,
root = Tk.Tk()
a =[ [0,1,2,3,4,5,6,\
f = figure(figsize=(3,3))
sp = f.add_subplot(111)
canvas = FigureCanvasTkAgg(f, master=root)
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
def displayData(maxCount=20, delayTimeMS=20, count=0):
fx = count % len(a)
ra = 
cnt = 0
v = a[fx][cnt]
for i in range(15*15):
if i == v:
cnt += 1
if cnt < len(a[fx]):
v = a[fx][cnt]
z = num.reshape(ra, (15,15))
sp.pcolor(transpose(z), cmap=cm.gray, norm=normalize())
count += 1
if count < maxCount:
root.after(delayTimeMS, displayData, maxCount, delayTimeMS,