Sourav K. Mandal wrote:
> Hello,
>
> (This is a different question for the same project that led me to file a
> bug about alpha blending in "contour" .)
>
> I want to overlay a number of exclusion regions in a 2D parameter scan.
> I generate each region with contourf in succession, like:
>
> contourf(x,y,unphys,(1),alpha=1,colors=('w','k'))
> contourf(x,y,excl,(1),alpha=0.5,colors=('w','m'))
> ...
>
> The problem as you might guess is that if I overlay many regions, the
> white level at each new region washes out the underlying non-white
> colors.
>
> Is there a "transparent" color I can use instead of white? Or, is there
> an alternative way to overlay regions that avoids this problem?
>
Until a grand reworking of the alpha mess occurs, here is a (verbose)
workaround showing how to set regions to be uncolored (transparent):
In [3]:cs = contourf(rand(10,10), colors=('r', 'g', 'b'))
In [4]:cs.levels
Out[4]:array([ 0. , 0.15, 0.3 , 0.45, 0.6 , 0.75, 0.9 , 1.05])
In [5]:cs.collections
Out[5]:<a list of 7 collections.PathCollection objects>
In [6]:cst = cs.collections[::3]
In [7]:for c in cst:
...: c.set_color('none')
...:
...:
In [8]:draw()
Alternatively, and more simply, why make the transparent regions in the
first place?
cs = contourf(rand(10,10), [0.5, 0.7], colors=('b'))
Here we specify a single pair of limits between which the color will be
blue.
Eric
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users