Making a Surface plot transparent

13 views (last 30 days)
I am trying to make my surfaces transparent so I can see both when they are on top of each other/behind the other.
I have one surface for my aci/acj graph called CritCon and one for my inequalities ineq1/ineq2 called Condition
I have tried 'FaceAlpha', 0.3 in the surf( ) command as well as Alpha(0.3) after the surf() command, neither seems to work.
Thank you!
%define the set parameters
meshsize=.01; %changing this to be lower gives weird graphs
g = 0.2;
%-------Param 0 ----------------
%define the range of x (deltai),y (betai) coordinates
%-------Param 0 ----------------
% Mesh Grid
[X,Y] = meshgrid(mui,bi);
%Inequality 1 is for Sij>0 and Ri>1.
%Inequality 2 is for Sji>0 and Rj>1.
ineq1= Y > (2*bj.*(X+g).*(g+muj).*(X+g+muj))./(bj.*g.*(X-muj)+(g+muj).*(X+2*g+muj).*(g+2*muj));
ineq2= Y < (bj.*(X+g).*(2*X+g).*(X+2*g+muj))./(bj.*g.*(X-muj)+2.*(X+g).*(g+muj).*(X+g+muj));
aci = (1+(-2).*X.*(g+2.*X).^(-1).*Y.*((-1).*g+(-1).*X+Y).^(-1))<=(0);
acj = (1+(-2).*bj.*(bj+(-1).*g+(-1).*muj).^(-1).*muj.*(g+2.*muj).^(-1))<=(0);
Condition = ineq1.*ineq2;
Condition(Condition==0) = NaN;
CritCon = aci.*acj;
surf(X,Y,CritCon,'EdgeColor', '[0.3010, 0.7450, 0.9330]','FaceAlpha',0.3)
hold on
surf(X,Y,Condition,'EdgeColor', '[0.6350, 0.0780, 0.1840]','FaceAlpha',0.3)
title('R_i,R_j>1 , S>0 (and crit cond) when \mu_j=0.4, b_j=2.34.')
hold off
  1 Comment
Walter Roberson
Walter Roberson on 1 Mar 2022
Edgecolor would normally be numeric not character vector.

Sign in to comment.

Accepted Answer

Benjamin Kraus
Benjamin Kraus on 1 Mar 2022
Edited: Benjamin Kraus on 1 Mar 2022
Your surface plots are each roughly 7500x7500 faces, and most (all) monitors have a resolution that is much lower than that. This means that each "face" of your surface is smaller than a pixel, but the edges between the faces are also larger than the faces themselves. This means what you are seeing is entirely the edge color, not the face color. Your best bet is to turn off the edge color, so all you can see are faces, then the transparency will work.
s1 = surf(X,Y,CritCon,'EdgeColor','none','FaceAlpha',0.3,'FaceColor',[0.3010, 0.7450, 0.9330])
hold on
s2 = surf(X,Y,Condition,'EdgeColor','none','FaceAlpha',0.3,'FaceColor', [0.6350, 0.0780, 0.1840])
Ursula Trigos-Raczkowski
Ursula Trigos-Raczkowski on 1 Mar 2022
Thank you again, this is extremely helpful.

Sign in to comment.

More Answers (1)

Johan on 1 Mar 2022
I think FaceAlpha does work but your mesh size is so small that you only see the edges plotted which are not transparent in your case. You can use EdgeAlpha to see if the graph looks better that way.
Walter Roberson
Walter Roberson on 1 Mar 2022
Good point.
Most of the time I use Edgecolor 'none' to avoid that problem

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!