3-D Visualization |
Creating a Single Polygon
A polygon is simply a patch with one face. To create a polygon, specify the coordinates of the vertices and color data with a statement of the form
For example, these statements display a 10-sided polygon with a yellow face enclosed by a black edge. The axis
equal
command produces a correctly proportioned polygon.
The first and last vertices need not coincide; MATLAB automatically closes each polygonal face of the patch. In fact, it is generally better to define each vertex only once, particularly if you are using interpolated face coloring.
Interpolated Face Colors
You can control many aspects of the patch coloring. For example, instead of specifying a single color, you can provide a range of numerical values that map the color at each vertex to a color in the figure colormap.
a = t(1:length(t)-1); %remove redundant vertex definition patch(sin(a),cos(a),1:length(a),'FaceColor','interp') colormap cool; axis equal
MATLAB now interpolates the colors across the face of the patch. You can color the edges of the patch the same way, by setting the edge colors to be interpolated. The command is
Specifying Patch Coloring provides more information on options for coloring patches.
Behavior of the patch Function | Multifaceted Patches |
© 1994-2005 The MathWorks, Inc.