%% Vary Patch Object Transparency
% Plot a line using the |patch| function. Set the last entry of |y| to
% |NaN| so that |patch| creates a line instead of a closed polygon.

% Copyright 2015 The MathWorks, Inc.


%%
% Define one transparency value per vertex by setting the
% |FaceVertexAlphaData| property to a column vector. Interpret the values
% as transparency values (0 is invisible, 1 is opaque) by setting the
% |AlphaDataMapping| property to |'none'|. Interpolate the transparency
% between vertices by setting the |EdgeAlpha| property to |'interp'|.

x = linspace(1,10,10);
y = sin(x);
y(end) = NaN; 

figure
alpha_values = linspace(0,1,10)'; 
patch(x,y,'red','EdgeColor','red',...
    'FaceVertexAlphaData',alpha_values,'AlphaDataMapping','none',...
    'EdgeAlpha','interp')