Thanks Eric. Yeah, I noticed the _lut attribute and conjectured that it was the most analogous structure. Can you please tell me more about it, e.g., why N+3? Is the fourth column an alpha spec? If so, would this be a way to give different colors different alpha values (which is something I want to be able to do; actually, what I want to do is to be able to specify a non-constant array of alpha values, i.e., I want direct pixel-to-pixel control over alpha values...) Anyway, I'll build some tools around it and submit as a "patch" for possible inclusion in future releases...
DG --- On Sun, 6/22/08, Eric Firing <[EMAIL PROTECTED]> wrote: > From: Eric Firing <[EMAIL PROTECTED]> > Subject: Re: [Matplotlib-users] More Matlab-like way to manipulate colormaps? > To: [EMAIL PROTECTED] > Cc: matplotlib-users@lists.sourceforge.net > Date: Sunday, June 22, 2008, 1:14 AM > David, > > There is no such API--maybe we should add some methods to > the base > Colormap so there would be--but you can do it yourself in > either of two > ways. > > First, you can generate a colormap from a list of colors, > and the colors > can be rgb triplets, so you could make your Nx3 array, do > whatever you > want with it, and then turn it into a colormap by using it > to initialize > a ListedColormap. (The ListedColormap accepts an Nx3 > array, or a list > of any valid mpl colorspecs.) > > Second, if you have any existing mpl Colormap instance, you > can directly > manipulate the _lut attribute; it is an ndarray and its > dimensions are > (N+3)x4. You might want to manipulate only the [:N,:3] > subarray of it. > The leading underscore means this attribute is not > intended for user > manipulation--but there is nothing to stop you from doing > it in a pinch > if necessary. > > Eric > > David Goldsmith wrote: > > Hi. Making progress. Caveat for what follows: the > last version of Matlab I used was like 6 or 7, I think - > it's been a little while - so for all I know, the > colormap manipulation API I've been able to discover in > the current MPL does correspond closely to the same thing in > the current Matlab. That said, said MPL colormap API is > much more "powerful" (and consequently > complicated) than I need, at least for right now. :-) Is > there a set of tools I'm not finding, or perhaps a > third-party add-on, that enables more Matlab-like colormap > manipulation? For example, I'm use to a (Matlab) > colormap simply being an Nx3 array of N RGB triples (or at > least that's the API), which one can then process using > standard array operators (+, *, etc.), methods (transpose, > flipud, fliplr, etc), etc. and create and apply new > colormaps by simply saying "colormap = <new N x 3 > array>" - are there tools which enable this manner > of manipulating MPL's colormap class instances? Or > > a "built-in" API to these that I'm not > finding? Thanks! > > > > DG > > > > PS: In case this is relevant, I'm using the OO > API, not pylab. Thanks again. > > > > > > > > > > > > > ------------------------------------------------------------------------- > > Check out the new SourceForge.net Marketplace. > > It's the best place to buy or sell services for > > just about anything Open Source. > > http://sourceforge.net/services/buy/index.php > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users