>>>>> "Pellegrini" == Pellegrini Eric <[EMAIL PROTECTED]> writes:
Pellegrini> Hi John, thank you very much for the hand.
Pellegrini> I think that I have found my mistake. I was
Pellegrini> launching my script trough "Idle" that seems to be the
Pellegrini> reason why it was to slow. Running my script with the
Pellegrini> command line or by double-clicking on it gave results
Pellegrini> similar to yours. Would you know why Idle application
Pellegrini> 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
ioff()
for x in somerange():
fill(...)
ion()
Then matplotlib will turn off drawing for the loop.
Pellegrini> By the way, using the Collection class, would you
Pellegrini> have any idea how to set different colors to the
Pellegrini> polygons ? Using set_color method change the color of
Pellegrini> 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
RGBA.
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
collection.set_array(asarray(c))
collection.set_cmap(cmap)
Collections are covered at
http://matplotlib.sf.net/matplotlib.collections.html and in the user's
guide PDF on the web site.
JDH
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users