|
From: Simon K. <ko...@we...> - 2008-11-21 09:49:33
|
Hi all,
I'd like to create a ListedColormap with different alpha values, like
...
[ 1. , 1. , 1. , 0.65],
[ 1. , 1. , 1. , 0.66],
[ 1. , 1. , 1. , 0.67],
[ 1. , 1. , 1. , 0.68],
[ 1. , 1. , 1. , 0.69],
[ 1. , 1. , 1. , 0.7 ],
[ 1. , 1. , 1. , 0.71],
[ 1. , 1. , 1. , 0.72],
[ 1. , 1. , 1. , 0.73],
[ 1. , 1. , 1. , 0.74],
[ 1. , 1. , 1. , 0.75],
[ 1. , 1. , 1. , 0.76],
[ 1. , 1. , 1. , 0.77],
[ 1. , 1. , 1. , 0.78],
[ 1. , 1. , 1. , 0.79],
...
meaning "map all my values to white, but with different alpha".
When I do something like this:
myColormap = matplotlib.colors.ListedColormap(my_rgba_array)
contourf(x,y,data,arange(0.1,1.05,0.05), cmap=myColormap)
it seems like my alpha values get changed to "1" deep inside
matplotlib.colors.Colormap/LinearSegmentedColormap/ListedColormap.
After looking at the source of matplotlib.colors, it seems to me that
different alpha values are something Colormap is not designed for.
Something like:
myColormap._lut = my_rgba_array
doesn't work.
What would be the best approach to create a Colormap with different
alphas? ListedColormap would be convinient, but I can also go with
LinearSegmentedColormap.
Regards
Simon
|