Show Sidebar Hide Sidebar

Filled Area Plots in MATLAB

How to make a filled area plot in MATLAB. An area chart displays a solid color between the traces of a graph.

% Learn about API authentication here: https://plot.ly/matlab/getting-started
% Find your api_key here: https://plot.ly/settings/api

y = [1, 5, 3;
     3, 2, 7;
     1, 5, 3;
     2, 6, 1];
fig = figure
area(y)

%--PLOTLY--%

% Strip MATLAB style by default!
response = fig2plotly(fig, 'filename', 'matlab-basic-area');
plotly_url = response.url;
% Learn about API authentication here: https://plot.ly/matlab/getting-started
% Find your api_key here: https://plot.ly/settings/api

trace1 = struct(...
  'x', [1, 2, 3, 4], ...
  'y', [0, 2, 3, 5], ...
  'fill', 'tozeroy', ...
  'type', 'scatter');
trace2 = struct(...
  'x', [1, 2, 3, 4], ...
  'y', [3, 5, 1, 7], ...
  'fill', 'tonexty', ...
  'type', 'scatter');
data = {trace1, trace2};
response = plotly(data, struct('filename', 'basic-area', 'fileopt', 'overwrite'));
plot_url = response.url
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.