I found that in scatter plots the alpha values given by individual
entries in the color list are ignored. Here an example that shows
different combinations of color and alpha arguments:
x = [1,2,3]
y = array([1,1,1])
c = [[1,0,0, 0.0],
[1,0,0, 0.5],
[1,0,0, 1.0]]
scatter(x, y, s = 200, c = 'r')
scatter(x, y + 1, s = 200, c = c)
scatter(x, y + 2, s = 200, c = c, alpha = 0.5)
scatter(x, y + 3, s = 200, c = 'g', alpha = 0.5)
Looking at the source in axes.py/scatter I found that replacing the
default value for the alpha keyword argument in the function header of
scatter from alpha=1.0 to alpha=None fixes this problem. Additionally, I
had to replace
collection.set_alpha(alpha)
by
if alpha is not None:
collection.set_alpha(alpha)
See also the attached diff file.
Gregor
Index: axes.py
===================================================================
--- axes.py (revision 6590)
+++ axes.py (working copy)
@@ -4873,7 +4872,7 @@
medians=medians, fliers=fliers)
def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
- vmin=None, vmax=None, alpha=1.0, linewidths=None,
+ vmin=None, vmax=None, alpha=None, linewidths=None,
faceted=True, verts=None,
**kwargs):
"""
@@ -5136,7 +5135,8 @@
transOffset = self.transData,
)
collection.set_transform(mtransforms.IdentityTransform())
- collection.set_alpha(alpha)
+ if alpha is not None:
+ collection.set_alpha(alpha)
collection.update(kwargs)
if colors is None:
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel