I want to plot a scatter plot with filled markers and make them semi-transparent so when two or more markers overlap, the overlapping area will be more opaque.
I naively thought
sg = scatter(rand(1000,1),rand(1000,1), 'filled');
alpha(0.5)
would work, but it doesn't. Also
set(get(sg, 'Children'), 'FaceAlpha', 0.2)
doesn't work. Any ideas?
AFAIK, you cannot change the alpha values of the plot markers in scatter
. One solution would be to patch
to draw markers yourself. Alpha values can be set for patch()
objects and you will get the desired effect when markers overlap. However, this can get quite cumbersome and will need to be customized to your needs.
See this related question, where the function defined in the question does exactly that. You can use that as a starting point and work from there.