Documentation

fewerbins

Decrease number of histogram bins

Description

example

N= fewerbins(h)decreases the number of bins in histogramhby 10% (rounded down to the nearest integer) and returns the new number of bins.

For bivariate histograms, this decreases the bin count in both thexandydirections.

N= fewerbins(h,direction), wherehmust be ahistogram2object, only decreases the number of bins in the dimension specified bydirection. Thedirectionoption can be'x','y', or'both'. The default value is'both'.

Examples

collapse all

Plot a histogram of 1,000 random numbers and return a handle to the histogram object.

x = randn(1000,1); h = histogram(x)

h = Histogram with properties: Data: [1000x1 double] Values: [1x23 double] NumBins: 23 BinEdges: [1x24 double] BinWidth: 0.3000 BinLimits: [-3.3000 3.6000] Normalization: 'count' FaceColor: 'auto' EdgeColor: [0 0 0] Show all properties

Usefewerbinsto decrease the number of bins in the histogram.

fewerbins(h); fewerbins(h)

ans = 18

Input Arguments

collapse all

Input histogram, specified as ahistogramorhistogram2object.

hcannot be a categorical histogram.

Direction to decrease the number of bins, specified as'x','y', or'both'. Specify'x'or'y'to only decrease the number of bins in that direction while leaving the number of bins in the other direction constant.

Output Arguments

collapse all

Number of bins, returned as a scalar or vector.Nis the new number of bins for the histogram after increase. For bivariate histogram plots,Nis a two-element vector,[nx ny].

Introduced in R2014b