image thumbnail

MATLAB Plot Gallery - Starirstep Plot

by

 

Create a stair-step plot

Stairstep_Plot

This is an example of how to create a stair-step plot in MATLAB®.

Read about the stairs function in the MATLAB® documentation.

Go to MATLAB Plot Gallery

% Load data on beak length
load beaksData beaks;

% Calculate histograms for the beak data
minBeak = min(beaks);
maxBeak = max(beaks);
nbins = minBeak:0.2:maxBeak;
[nB, xB] = hist(beaks, nbins);

% Create a stair plot of beak sizes
figure;
stairs(xB, nB/sum(nB), 'b');

% Add title and axis labels
title('Ground finch beak sizes');
xlabel('Beak size in mm');
ylabel('Fraction of birds with beak size');

Contact us