scatter and alpha settings

Dear developers,

in matplotlib 0.98.3 I discoverd that in scatter individual alpha settings (by giving a list of rgba values) are ignered. Here an example that show this behaviour: All points show the same alpha value as given by the alpha keyword argument. (Omitting it equals to the setting alpha=1).

from pylab import *

x = [1,2,3]
y = [1,2,3]

c = [[1,0,0, 0.0],
     [1,0,0, 0.5],
     [1,0,0, 1.0]]

gca()
cla()
scatter(x,y, c=c, s = 200, alpha = 0.5)
draw()
show()

I had a look at the sources. In axes.py/scatter I simply removed the line

collection.set_alpha(alpha)

The recent svn version also contains this line.
With this change it worked as expected, also e.g. for the case of a single color for all points,

scatter(x,y, c = 'r', alpha = 0.5)

Gregor

Gregor Thalhammer wrote:

Dear developers,

in matplotlib 0.98.3 I discoverd that in scatter individual alpha settings (by giving a list of rgba values) are ignered. Here an example that show this behaviour: All points show the same alpha value as given by the alpha keyword argument. (Omitting it equals to the setting alpha=1).

from pylab import *

x = [1,2,3]
y = [1,2,3]

c = [[1,0,0, 0.0],
     [1,0,0, 0.5],
     [1,0,0, 1.0]]

gca()
cla()
scatter(x,y, c=c, s = 200, alpha = 0.5)
draw()
show()

I had a look at the sources. In axes.py/scatter I simply removed the line

collection.set_alpha(alpha)

You are correct that there is a bug, in that the alpha in rgba arrays is always overridden, but removing that line is not the solution. I will try to fix it in the next few days. I think the intention was that alpha=None would be used to mean "don't disturb existing alpha in an rgba array; but use alpha=1 if color comes in as other than rgba", but this has not been propagated uniformly. Small changes in quite a few places may be needed.

Eric

···

The recent svn version also contains this line.
With this change it worked as expected, also e.g. for the case of a single color for all points,

scatter(x,y, c = 'r', alpha = 0.5)

Gregor