Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scatter should take array for alpha #3097

Closed
endolith opened this issue May 31, 2014 · 2 comments
Closed

scatter should take array for alpha #3097

endolith opened this issue May 31, 2014 · 2 comments

Comments

@endolith
Copy link
Contributor

Would it make sense for scatter to take an array for alpha that sets the alpha for each point?

For example, with data like:

x = [1, 2, 3, 4]
y = [4, 3, 2, 1]
alpha = [0.2, 0.3, 0.8, 1.0]

I have to do something like this:

c = tile((0, 0, 1), (len(alpha), 1))
c = hstack((c, transpose([alpha])))
s = scatter(x, y, color=c, edgecolors=c)

but it could just be like this:

s = scatter(x, y, color='b', alpha=alpha)
@efiring
Copy link
Member

efiring commented May 31, 2014

Having the alpha kwarg as a scalar only is deep-seated in mpl; I don't think it makes sense to start changing this piecemeal, if at all. If you want an array of colors with varying alpha, it makes more sense to make the appropriate rgba array, as you show above. If you need it often, you could make a little helper function.

@tacaswell
Copy link
Member

I agree with @efiring adding this would cause more grief than it would save.

I would do your array construction as c = np.asarray([(0, 0, 1, a) for a in alpha]) or use a colormap which sets the alpha (http://matplotlib.org/examples/pylab_examples/custom_cmap.html). Closing as wontfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants