Ok, so the patch
function lets us draw multiple polygons with e.g.
patch(X,Y,'r')
where X
and Y
are m-by-n matrices. This draws n polygons with m vertices.
But what if I want each of those n polygons to have a unique alpha transparency value?
patch(X,Y,'r', ??? SOME CODE TO USE A VECTOR OF ALPHA VALUES ???)
The documentation is confusing me to death. I can't use a for
loop, since I need to draw many patch objects very quickly. Could somebody kindly provide a code example? Thanks everyone.
Looks like the FaceVertexAlphaData
property is the key: Here is some sample code:
X = [...
1 2 3 ; ...
4 5 6 ; ...
7 8 9 ; ...
10 11 12];
Y = [...
2 5 8; ...
3 6 9; ...
1 4 7; ...
-1 3 6];
h = patch( X, Y, 'r');
set(h,'FaceAlpha','flat','FaceVertexAlphaData',[.2; .4; .8])
docsearch patch properties
for more information.