Hi John, thank you very much for the hand.
> I think that I have found my mistake. I was
> launching my script trough "Idle" that seems to be the
> reason why it was to slow. Running my script with the
> command line or by double-clicking on it gave results
> similar to yours. Would you know why Idle application
> slows down so much the execution of my script ?
Probably because you are running in "interactive" mode and matplotlib
is redrawing your figure on every fill command. See
http://matplotlib.sf.net/interactive.html for details. You can
temporarily turn interaction on and off with the ion and ioff
functions. Something like
for x in somerange():
Then matplotlib will turn off drawing for the loop.
> By the way, using the Collection class, would you
> have any idea how to set different colors to the
> polygons ? Using set_color method change the color of
> all the plygons.
You can pass in a sequence of facecolors the length of your number of
polygons. Each element of the sequence must be RGBA, but you can use
matplotlib's color converter to convert an arbitrary color argument to
from colors import colorConverter
colors = [colorConverter.to_rgba(x) for x in ('red', 'green', 'black', 'y', '0.8')]
collection = PolyCollection(verts, facecolors = colors)
You can also use colormapping with a PolyCollection where "c" below is an array of scalar intensities and cmap is a matplotlib.cm colormap, eg cm.jet and norm
Collections are covered at
http://matplotlib.sf.net/matplotlib.collections.html and in the user's
guide PDF on the web site.