How to make a plot using the "facecolor" option in "patch" but still keeping markers of points displayed at the top of other objects?
If "FT.facealpha = 0.2" (line 25 of code) is commented out, point markers sit nicely at the top of other objects, as intented. If the opacity option is used, then markers appear at the bottom (or become transparent), which is an undesired effect. Plotting points at the end or using "uistack" doesn't resolve the issue. Please see the code below the message.
Many thanks,
Viki
figure;hold on;axis([-0.5 3.5 -0.5 3.5]);axis equal; box on;% set of 9 points with their (x,y) coords
P = [1 0; 0 1; 1 2; 2 1; 2 0; 2 2; 2 3; 3 0; 3 2];% edges
E = [1 5; 3 7; 4 8; 7 9]; % each row defines vertices of an edge
for i = 1:size(E,1); a = P(E(i,1),:); % coords of vertex "a" on edge [a,b]
b = P(E(i,2),:); % vertex "b"
line([a(1) b(1)],[a(2) b(2)], 'color', 'm', 'LineWidth',2);end% filled triangles
T = [2 3 4; 4 6 9]; % each row defines a triangle (vertices in P)
for i = 1:size(T,1) a = P(T(i,1),:); % coords of vertex "a" in triangle [a,b,c]
b = P(T(i,2),:); % vertex "b" c = P(T(i,3),:); % vertex "c"
FT.vertices = [a;b;c]; FT.faces = [1 2 3]; FT.facecolor = 'g'; FT.facealpha = 0.2; % COMMENT THIS LINE
patch(FT);end% plot points
h = plot(P(:,1),P(:,2),'o',... 'MarkerSize',10,'MarkerFaceColor','y','MarkerEdgeColor','b','LineWidth',2);uistack(h,'top');
Best Answer