|
From: Paul I. <piv...@gm...> - 2008-11-23 08:01:32
|
I took a stab at it, how does this look?
I also took the liberty of adding alpha to LinearSegmentedColormap and
updated its docstring changing two somewhat ambiguous uses of the word
'entry' with 'key' and 'value'.
tested with
In [1]: import matplotlib; import numpy as np
In [2]: my_rgba_array= np.array( [[ 1., 1., 1., 0.65],
[ 1., 0., 0., 0.79]])
In [3]: myColormap = matplotlib.colors.ListedColormap(my_rgba_array)
In [4]: myColormap.__call__(.1)
Out[4]: (1.0, 1.0, 1.0, 0.65000000000000002)
In [5]: myColormap.__call__(.9)
Out[5]: (1.0, 0.0, 0.0, 0.790000000000000
In [6]: my_rgba_array= np.array( [ [ 1. , 1. , 1. ],
[ 1. , 0. , 0. ]])
In [7]: myColormap = matplotlib.colors.ListedColormap(my_rgba_array)
In [8]: myColormap.__call__(.1)
Out[8]: (1.0, 1.0, 1.0, 1.0)
In [9]: myColormap.__call__(.9)
Out[9]: (1.0, 0.0, 0.0, 1.0)
cheers,
Paul Ivanov
John Hunter, on 2008-11-21 05:52, wrote:
> On Fri, Nov 21, 2008 at 2:45 AM, Simon Kammerer <ko...@we...> wrote:
>
>> After looking at the source of matplotlib.colors, it seems to me that
>> different alpha values are something Colormap is not designed for.
>
> Yes, it looks like the colormap only holds the RGB channels, but it
> also looks fairly straightforward to patch the code to support the
> fourth channel. Is this something you'd like to tackle?
>
> JDH
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
|