bug in scatter?

Hi,

The following script produces a single point that is green and translucent:

import matplotlib.pyplot as mpl

fig = mpl.figure()
ax = fig.add_subplot(111)
ax.scatter([0.],[0.],c=1.,alpha=0.2,vmin=0,vmax=2.0,cmap=mpl.cm.jet)
fig.canvas.draw()

and the following script produces a single point that is red and definitely
not translucent, because the color defined by c= is above vmax.

import matplotlib.pyplot as mpl

fig = mpl.figure()
ax = fig.add_subplot(111)
ax.scatter([0.],[0.],c=1.,alpha=0.2,vmin=0,vmax=0.5,cmap=mpl.cm.jet)
fig.canvas.draw()

Whether this is intentional or not, I'm not sure, but I would have expected
that alpha overrides the fact the color is out of bounds. In any case, this
pops up sometimes if I am plotting multiple points with different colors
given by an array, because vmax and vmin are automatically computed, and
because of numerical accuracy sometimes the 'brightest' point loses it's
alpha. The following example illustrates this:

import matplotlib.pyplot as mpl

import numpy as np

np.random.seed(-12421412)

x = np.random.random(10000)
y = np.random.random(10000)
c = np.random.random(10000)

fig = mpl.figure()
ax = fig.add_subplot(111)
ax.scatter(x,y,c=c,alpha=0.01,cmap=mpl.cm.jet)
fig.canvas.draw()

Is this a bug in the way the colormap/alpha is handled?

Thanks,

Thomas

···


View this message in context: http://www.nabble.com/bug-in-scatter--tp24811933p24811933.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Just a quick note - the last script in my previous email is wrong. I don't
get the problem in that case, I get it if the arrays are 32-bit:

import matplotlib.pyplot as mpl

import numpy as np

np.random.seed(-12421412)

x = np.random.random(10000).astype(np.float32)
y = np.random.random(10000).astype(np.float32)
c = np.random.random(10000).astype(np.float32)

fig = mpl.figure()
ax = fig.add_subplot(111)
ax.scatter(x,y,c=c,alpha=0.01,cmap=mpl.cm.jet)
fig.canvas.draw()

which explains why there is probably some small numerical inaccuracy in
deciding whether the color value is above the maximum of the range (if the
latter is calculated in 64-bit). However, the question of why alpha gets set
to 1 for color values above the maximum still holds.

Tom

···


View this message in context: http://www.nabble.com/bug-in-scatter--tp24811933p24812570.html
Sent from the matplotlib - users mailing list archive at Nabble.com.