MATLAB Examples

This is an example of how to create transparent objects in MATLAB®.

Read about the FaceAlpha property in the MATLAB documentation. This feature is available in R2015b or newer.

For more examples, go to MATLAB Plot Gallery

% Create 2 sets of data
x = linspace(0,10);
y1 = 4 + sin(x).*exp(0.1*x);
y2 = 4 + cos(x).*exp(0.1*x);

% Create semitransparent area plots
figure
area(x,y1,'FaceColor','b','FaceAlpha',.3,'EdgeAlpha',.3)
hold on
area(x,y2,'FaceColor','r','FaceAlpha',.3,'EdgeAlpha',.3)
hold off

% Add title
title('Semi-transparent area plots')