The following was sent unintentionally in private e-mail (my e-mail program always selects the sender as recipient first :-( ). I think the solution by Jae-Joon is also elegant, but nevertheless the following may be useful also (and maybe also in other places):
---------- Forwarded message ---------- From: Friedrich Romstedt <friedrichromst...@gmail.com> Date: 2010/2/24 Subject: Re: [Matplotlib-users] Looping through all the built-in colormaps To: David Goldsmith <d_l_goldsm...@yahoo.com> > 0) is there some "elegant" way to do what I want to do? Don't know whether it's elegant or not, but it should do the job: for cmap_name in dir(cm): cmap_object = getattr(cm, cmap_name) if isinstance(cmap_object, matplotlib.colors.LinearSegmentedColormap): [...] > 1) why doesn't this: > >>>> for cmap in dir(cm): >>>> try: >>>> ax.imshow(image, cmap) >>>> canvas.print_figure('image_'+cmap) >>>> except: >>>> pass > > "work" (i.e., simply bypass those elements of dir(cm) which cause imshow to > raise an exception, but then continue on as if nothing had happened)? Is > this a bug? I guess it's because you have messed up with the internals of the axes, when passing an invalid entry. It gets stored somewhere without check, and then causes subsequent error occuring before the next element is applied fully, I guess. It's more a bug of your code than of matplotlib, because your argument did not fulfil specification :-) Friedrich ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users