Navigation

Operators and Keywords

Function List:

C++ API

: area (y)
: area (x, y)
: area (…, lvl)
: area (…, prop, val, …)
: area (hax, …)
: h = area (…)

Area plot of the columns of y.

This plot shows the contributions of each column value to the row sum. It is functionally similar to plot (x, cumsum (y, 2)), except that the area under the curve is shaded.

If the x argument is omitted it defaults to 1:rows (y). A value lvl can be defined that determines where the base level of the shading under the curve should be defined. The default level is 0.

Additional property/value pairs are passed directly to the underlying patch object.

If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

The optional return value h is a graphics handle to the hggroup object comprising the area patch objects. The "BaseValue" property of the hggroup can be used to adjust the level where shading begins.

Example: Verify identity sin^2 + cos^2 = 1

t = linspace (0, 2*pi, 100)';
y = [sin(t).^2, cos(t).^2];
area (t, y);
legend ("sin^2", "cos^2", "location", "NorthEastOutside");

See also: plot, patch.

Demonstration 1

The following code

 ## Verify identity sin^2 + cos^2 = 1
 clf;
 t = linspace (0, 2*pi, 100)';
 y = [sin(t).^2, cos(t).^2];
 area (t, y);
 axis tight
 legend ("sin^2", "cos^2", "location", "NorthEastOutside");
 title ("area() plot");

Produces the following figure

Figure 1

Demonstration 2

The following code

 ## Show effects of setting BaseValue
 clf;
 x = [-2:0.1:2]';
 y = x.^2 - 1;
 subplot (1, 2, 1)
  area (x, y);
  title ({"Parabola y = x^2 -1";"BaseValue = 0"});
 subplot (1, 2, 2)
  h = area (x, y);
  set (h, "basevalue", -1);
  title ({"Parabola y = x^2 -1";"BaseValue = -1"});

Produces the following figure

Figure 1

Demonstration 3

The following code

 clf;
 x = 0:10;
 y = rand (size (x));
 h = area (x, y);
 set (h, "ydata", sort (get (h, "ydata")));
 title ("area() plot of sorted data");

Produces the following figure

Figure 1

Package: octave