|
From: David G. <d_l...@ya...> - 2008-09-16 13:37:17
|
Excellent, thanks!!!
DG
--- On Tue, 9/16/08, John Hunter <jd...@gm...> wrote:
> From: John Hunter <jd...@gm...>
> Subject: Re: [Matplotlib-users] 'Inverting' a colormap (was "Next problem: pixel-to-pixel alpha variation")
> To: d_l...@ya...
> Cc: mat...@li...
> Date: Tuesday, September 16, 2008, 12:46 PM
> On Tue, Sep 16, 2008 at 2:40 PM, David Goldsmith
> <d_l...@ya...> wrote:
> > --- On Tue, 9/9/08, David Goldsmith
> <d_l...@ya...> wrote:
> >
> >> eventually ... I'd like to do what John
> implies
> >> is possible, i.e., "invert" a cm back to
> its RGB
> >> table - John (or anyone) can you short-cut the
> learning
> >> process for me w/ a code example of how to do
> this? :-)
> >> Thanks!
> >>
> >> DG
> >
> > No one has a shareable code example of how to invert a
> colormap to an RGB array?
>
> Is this what you are looking for? (outputs RGBA but just
> override the
> alpha or extract the RGB part)
>
>
> >In [9]: import matplotlib.cm as cm
>
> In [10]: x = np.arange(0, 1, 0.1)
>
> In [11]: print cm.jet(x)
> [[ 0. 0. 0.5 1. ]
> [ 0. 0. 0.9456328 1. ]
> [ 0. 0.3 1. 1. ]
> [ 0. 0.69215686 1. 1. ]
> [ 0.16129032 1. 0.80645161 1. ]
> [ 0.49019608 1. 0.47754586 1. ]
> [ 0.80645161 1. 0.16129032 1. ]
> [ 1. 0.77051561 0. 1. ]
> [ 1. 0.40740741 0. 1. ]
> [ 0.9456328 0.02977487 0. 1. ]]
|