area

  • area(X, Y) plots area under the curve of plot(X, Y)
  • area(X) plots the vector X or stacked areas based on X's columns

Area under exp(-x)

x = -3:0.1:3
area(x, exp(-x))

Negative values default handling

x = linspace(0,1)
y = sin(4*pi*x).*exp(-5*x)
area(x, y)

Changing base level

options = struct('areaBase', 4)
Y = [1 5 3; 2 2 2; 3 3 3]
area(Y(:,1), Y(:,2), options)

Specifying line and area colors

options = struct
options.areaStroke = '#ffcc99'
options.lineStroke = 'red'
x = -2*pi:.01:2*pi
y = sin(x)./x
area(x, y, options)

Specifying area above or below base level color

options = struct
options.areaAboveStroke = '#339966'
x = -2*pi:.01:2*pi
y = sin(x)
area(x, y, options)

Specifying area above and below base level colors

options = struct
options.areaAboveStroke = '#339966'
options.areaBelowStroke = '#c6ecd9'
options.areaBase = 0.2
x = -0.5*pi:.1:4*pi
y = sin(x)./x
area(x, y, options)

Generating stacked areas

x = [4 6 10]
y = [2, 8, 2
     1, 5, 10
     4, 9, 2]
area(x, y)

Specifying colors for stacked areas

options = struct('areaColors', {'Gray','GoldenRod','Gainsboro'})
Y = [2, 8, 2
     1, 5, 10
     4, 9, 2];
area(Y, options)

Table input

t = table([1;3], [2;3], [1;2], 'VariableNames', {'Jan', 'Feb', 'Mar'}, 'RowNames', {'LN', 'MAD'})
area(t)

See also

plot | bar | histogram