Problem with AlphaData property

5 views (last 30 days)
Leo on 27 Nov 2021
Answered: Star Strider on 27 Nov 2021
I have a figure of several plots. I want each plot to have its own gradient fill (meaning maximum: full color, minimum: fully transparent; separately for each plot). I wrote a simple example, unfortunately the result is not according to my ideas. The maximum for the second plot does not have a solid red color, but is already partially transparent. Why? And how would that be right?
Color1 = 'r';
hold on
% Plot 1
x = 0:0.2:10;
y = sin(x)+10;
xx = [x;x];
yy = [y;y*0];
plot1 = surf(xx,yy,xx*0,'alphadata',yy,'facealpha','interp','edgecolor','none',"FaceColor",Color1);
% Plot 2
x2 = 0:0.2:10;
y2 = sin(x2)+5;
xx2 = [x2;x2];
yy2 = [y2;y2*0];
plot2 = surf(xx2,yy2,xx2*0,'alphadata',yy2,'facealpha','interp','edgecolor','none',"FaceColor",Color1);
Figure below is as I would like it.

Answers (1)

Star Strider
Star Strider on 27 Nov 2021
The FaceAlpha (transparency) value is set to 'interp' and it is doing exactly what it is told to do!
It will likely be necessary to experiment to get the desired result. (I have no idea what the desired result is, so I have no idea what would need to be changed.)





Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!