Create patch object from x and y with color c and insert in the current axes object. Return handle to patch object.
For a uniform colored patch, c can be given as an RGB vector, scalar value referring to the current colormap, or string value (for example, "r" or "red").
The following code
## Patches with same number of vertices close all; t1 = (1/16:1/8:1)'*2*pi; t2 = ((1/16:1/8:1)' + 1/32)*2*pi; x1 = sin(t1) - 0.8; y1 = cos(t1); x2 = sin(t2) + 0.8; y2 = cos(t2); patch([x1,x2],[y1,y2],'r');
Produces the following figure
![]() |
The following code
## Unclosed patch close all; t1 = (1/16:1/8:1)'*2*pi; t2 = ((1/16:1/16:1)' + 1/32)*2*pi; x1 = sin(t1) - 0.8; y1 = cos(t1); x2 = sin(t2) + 0.8; y2 = cos(t2); patch([[x1;NaN(8,1)],x2],[[y1;NaN(8,1)],y2],'r');
Produces the following figure
![]() |
The following code
## Specify vertices and faces separately close all; t1 = (1/16:1/8:1)'*2*pi; t2 = ((1/16:1/16:1)' + 1/32)*2*pi; x1 = sin(t1) - 0.8; y1 = cos(t1); x2 = sin(t2) + 0.8; y2 = cos(t2); vert = [x1, y1; x2, y2]; fac = [1:8,NaN(1,8);9:24]; patch('Faces',fac,'Vertices',vert,'FaceColor','r');
Produces the following figure
![]() |
The following code
## Property change on multiple patches close all; t1 = (1/16:1/8:1)'*2*pi; t2 = ((1/16:1/8:1)' + 1/32)*2*pi; x1 = sin(t1) - 0.8; y1 = cos(t1); x2 = sin(t2) + 0.8; y2 = cos(t2); h = patch([x1,x2],[y1,y2],cat (3,[0,0],[1,0],[0,1])); pause (1); set (h, 'FaceColor', 'r');
Produces the following figure
![]() |