%% Adjust Properties of Histogram Object
% This example creates a histogram object, and then shows how to adjust the properties of the histogram to affect the output display.
% Create a histogram for all of the prime numbers less than 10,000,000. Specify an output argument to return the histogram object, h.

x = primes(1e7);
h = histogram(x)

%
% Change the normalization of the histogram by setting the Normalization property to 'probability'.

h.Normalization = 'probability';

%
% Use horizontal bars for the histogram.

h.Orientation = 'horizontal';

%
% Zoom in to a specific range of bins. When you set BinLimits, the BinLimitsMode automatically changes to 'manual'.

h.BinLimits = [1e6,2e6];

%
% Zoom back out to the original bin scaling by switching BinLimitsMode back to 'auto'.

h.BinLimitsMode = 'auto';

%
% Change the number of bins in the histogram.

h.NumBins = 200;

%
% Create a vertical stair histogram.

h.Orientation = 'vertical';
h.DisplayStyle = 'stairs';

% Copyright 2015 The MathWorks, Inc.