How to use alphadata for markers in scatter plot so each marker has a different alpha value?
73 views (last 30 days)
In the newest release of MATLAB marker transparency was implemented for scatter plots. However, as far as I can tell, one can only set a global alpha value that applies to ALL of the markers. I would like to have different alpha values for each marker, just like how one can assign different colors to each marker. How might I achieve this?
I envision something like:
SizeData = 10;
hS = scatter(X,Y,SizeData,ColorData,'filled',AlphaData);
I would like the result to be a scatter plot with the i-th marker located at [X(i),Y(i)] and colored by the value in ColorData(i), and having a transparency set by AlphaData(i). Any suggestions?
I have tried to achieve this using patch objects, since you can specify color and alpha data for each vertex, and try to just set the faces and edges to have no color. Unfortunately the FaceVertexCData and FaceVertexAlphaData don't seem to apply to the vertex Markers, all I can do is have it influence interpolated face color and face alpha, which is not what I'm going for.
Prannay Jain on 7 Apr 2017
I work for MathWorks and I have provided this feedback to the developers.
As a work around, you can set the alpha for every plot of the marker iteratively:
ax = axes;
for i = 1:10
s = scatter(10*rand(1),10*rand(1),36,rand(1,3),'filled');
s.MarkerFaceAlpha = rand(1); %%marking every maker with different alpha value