fewerbins

Reduces the number of bins of an existing histogram object.

Category: Graphics > 2-D and 3-D Plots

Syntax

fewerbins(h)

Makes the histogram h use fewer, wider bins.

n = fewerbins(h)

Also returns the new number of bins.

Description

The function changes the binning of h in place and the figure is redrawn with coarser bins. Each call lowers the bin count by one step; calling it repeatedly keeps coarsening. morebins does the opposite.

Input arguments

h
Histogram object created by histogram.

Output arguments

n
Number of bins after the change.

Example

Coarser bins

h = histogram(1:100);
before = h.NumBins
after = fewerbins(h)
Output
before = 5
after = 4

See also

morebins histogram histcounts hist