|MATLAB Function Reference|
Filled area 2-D plot
An area graph displays elements in
Y as one or more curves and fills the area beneath each curve. When
Y is a matrix, the curves are stacked showing the relative contribution of each row element to the total height of the curve at each x interval.
plots the vector
Y or the sum of each column in matrix
Y. The x-axis automatically scales to
area(X,Y) is the same as
plot(X,Y) except that the area between
Y is filled. When
Y is a matrix,
area(X,Y) plots the columns of
Y as filled areas. For each
X, the net result is the sum of corresponding values from the columns of
X is a vector,
length(X) must equal
X must be monotonic. If
X is a matrix,
size(X) must equal
size(Y) and each column of
X must be monotonic. To make a vector or matrix monotonic, use
specifies the base value for the area fill. The default
0. See the
BaseValue property for more information.
area(...,' specifies property name and property value pairs for the patch graphics object created by
plots into the axes with handle
axes_handle instead of the current axes (
h = area(...)
returns handles of areaseries graphics objects.
Backward Compatible Version
hpatches = area('v6',...)
returns the handles of patch objects instead of areaseries objects for compatibility with MATLAB 6.5 and earlier. See patch object properties for a discussion of the properties you can set to control the appearance of these area graphs.
See Plot Objects and Backward Compatibility for more information.
Creating an area graph of an m-by-n matrix creates n areaseries objects (i.e., one per column), whereas a 1-by-n vector creates one area object.
Note that some areaseries object properties that you set on an individual areaseries object set the value for all areaseries objects in the graph. See the property descriptions for information on specific properties.
Stacked Area Graph
This example plots the data in the variable
Y as an area graph. Each subsequent column of
Y is stacked on top of the previous data. Note that the figure colormap controls the coloring of the individual areas. You can explicitly set the color of an area using the
Adjusting the Base Value
The area function uses a y-axis value of 0 as the base of the filled areas. You can change this value by setting the area
BaseValue property. For example, negate one of the values of Y from the previous example and replot the data.
The area graph now looks like this:
BaseValue property improves the appearance of the graph:
Note that setting the
BaseValue property on one areaseries object sets the values of all objects.
Specifying Colors and Line Styles
You can specify the colors of the filled areas and the type of lines used to separate them.
Area, Bar, and Pie Plots for related functions
Area Graphs for more examples
Areaseries Properties for property descriptions
© 1994-2005 The MathWorks, Inc.