Filled area 2-D plot
h = area(...)
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.
area(X,Y) For vectors X and Y, area(X,Y) is the same as plot(X,Y) except that the area between 0 and 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 rows of Y.
If X is a vector, length(X) must equal length(Y). If X is a matrix, size(X) must equal size(Y).
area(...,basevalue) specifies the base value for the area fill. The default basevalue is 0. See the BaseValue property for more information.
area(axes_handle,...) plots into the axes with the handle axes_handle instead of into the current axes (gca).
Creating an area graph of an m-by-n matrix creates n areaseries objects (that is, one per column), whereas a 1-by-n vector creates one areaseries object.
Some areaseries object properties that you set on an individual areaseries object set the values for all areaseries objects in the graph. See the property descriptions for information on specific properties.
Plot the data in matrix Y as an area graph.
Y = [1, 5, 3; 3, 2, 7; 1, 5, 3; 2, 6, 1]; figure area(Y)
By default, area uses the y-axis as the base value. Change the base value by setting the basevalue input argument to -4.
Y = [1, 5, 3; 3, 2, 7; 1, 5, 3; 2, 6, 1]; figure basevalue = -4; area(Y,basevalue)
Create an area plot of the data in matrix Y. Set the line style and line width for the three areaseries objects created, one for each column in Y. Store the areaseries object handles in vector h.
Y = [1, 5, 3; 3, 2, 7; 1, 5, 3; 2, 6, 1]; figure h = area(Y,'LineStyle',':',... 'LineWidth',2);
Use the areaseries object handles to specify a different face color for each object.
set(h(1),'FaceColor',[0,0.25,0.25]); set(h(2),'FaceColor',[0,0.5,0.5]); set(h(3),'FaceColor',[0,0.75,0.75]);