%% Vary Transparency Across Data Points
% You can vary the transparency of scattered points by setting the AlphaData property to a vector of different opacity values. To ensure the scatter plot uses the AlphaData values, set the MarkerFaceAlpha property to 'flat'.
% Create a set of normally distributed random numbers. Then create a scatter plot of the data with filled markers.

x = randn(1000,1);
y = randn(1000,1);
s = scatter(x,y,'filled');

%
% Set the opacity of each point according to its distance from zero.

distfromzero = sqrt(x.^2 + y.^2);
s.AlphaData = distfromzero;
s.MarkerFaceAlpha = 'flat';

% Copyright 2020 The MathWorks, Inc.