patch
Draws one or more filled polygons from vertex coordinates or from faces and vertices.
Category: Mathematics > Computational Geometry
Syntax
patch(X, Y, C)
Draws the polygon with vertices (X, Y) filled with the color C.
patch('Faces', F, 'Vertices', V)
Draws the polygons listed in the face matrix F, whose indices refer to the rows of V.
patch(___, Name, Value)
Sets properties such as 'FaceColor', 'EdgeColor' or 'FaceAlpha'.
p = patch(___)
Returns the patch object so its properties can be changed later.
Description
patch is the low-level primitive behind filled shapes. Unlike fill, it can draw many polygons in one object and takes the face-vertex description used by meshes: a list of points plus a list of polygons that index into it. The polygon is closed automatically and drawn in the current axes.
A face can have any number of vertices; rows of Faces with fewer vertices than the matrix width are padded with NaN.
Input arguments
X, Y- Vectors with the vertex coordinates. If they are matrices, each column is a separate polygon.
C- Fill color: a color name such as
'r', or an RGB triplet. 'Faces', 'Vertices'- Face-vertex form:
Verticesholds one point per row andFacesone polygon per row, as vertex indices. 'FaceAlpha'- Transparency of the fill, from 0 (invisible) to 1 (opaque).
Output arguments
p- A patch object with properties like
Faces,Vertices,FaceColor,EdgeColorandFaceAlpha.
Example
A triangle and a two-triangle square
figure
patch([0 1 0.5], [0 0 1], 'g')
hold on
V = [2 0; 3 0; 3 1; 2 1];
F = [1 2 3; 1 3 4];
p = patch('Faces', F, 'Vertices', V, 'FaceColor', 'b', 'FaceAlpha', 0.5);
axis equal