Mathematica > Visualization and Graphics > Data Visualization >

Histogram

Histogram[{x1, x2, ...}]
plots a histogram of the values xi.
Histogram[{x1, x2, ...}, w]
plots a histogram with bin width specification w.
Histogram[{x1, x2, ...}, w, hspec]
plots a histogram with bin heights computed according to the specification hspec.
Histogram[{data1, data2, ...}, ...]
plots histograms for multiple datasets datai.
  • Histogram[data] by default plots a histogram with equal bin widths chosen to approximate an assumed underlying smooth distribution of the values xi.
  • The following bin width specifications can be given:
nuse n bins
{dx}use bins of width dx
{xmin,xmax,dx}use bins of width dx from xmin to xmax
{{b1,b2,...}}use the bins [b1, b2), [b2, b3), ...
Automaticdetermine bin widths automatically
"name"use a named binning method
fwapply fw to get an explicit bin specification {b1, b2, ...}
  • Possible named binning methods include:
"Sturges"compute the number of bins based on the length of data
"Scott"asymptotically minimize the mean square error
"FreedmanDiaconis"twice the interquartile range divided by the cube root of sample size
"Wand"one-level recursive approximate Wand binning
"Log"logarithmic bin widths
  • The function fw in Histogram[data, fw] is applied to a list of all xi, and should return an explicit bin list {b1, b2, ...}.
  • Different forms of histogram can be obtained by giving different bin height specifications hspec in Histogram[data, w, hspec]. The following forms can be used:
"Count"the number of values lying in each bin
"Probability"fraction of values lying in each bin
"ProbabilityDensity"fraction of values divided by bin width
"LogCount", "LogProbability", "LogProbabilityDensity"logarithmic heights
fhheights obtained by applying fh to bins and counts
  • The function fh in Histogram[data, w, fh] is applied to two arguments: a list of bins {{b1, b2}, {b2, b3}, ...}, and corresponding list of counts {c1, c2, ...}. The function should return a list of heights to be used for each of the ci.
  • Only values xi that are real numbers are assigned to bins; others are taken to be missing.
  • In Histogram[{data1, data2, ...}, ...], automatic bin locations are determined by combining all the datasets datai.
  • Histogram[{..., wi[datai, ...], ...}, ...] renders the histogram elements associated with dataset datai according to the specification defined by the symbolic wrapper wi.
AspectRatio1/GoldenRatiooverall ratio of width to height
AxesTruewhether to draw axes
BarOriginBottomorigin of histogram bars
ChartBaseStyleAutomaticoverall style for bars
ChartElementFunctionAutomatichow to generate raw graphics for bars
ChartElementsAutomaticgraphics to use in each of the bars
ChartLabelsNonecategory labels for datasets
ChartLayoutAutomaticoverall layout to use
ChartStyleAutomaticstyle for bars
ChartLegendsNonelegends for data elements and datasets
ColorFunctionAutomatichow to color bars
ColorFunctionScalingTruewhether to normalize arguments to ColorFunction
LabelingFunctionAutomatichow to label elements
LegendAppearanceAutomaticoverall appearance of legends
PerformanceGoal$PerformanceGoalaspects of performance to try to optimize
  • Possible settings for ChartLayout include "Overlapped" and "Stacked".
  • The arguments supplied to ChartElementFunction are the bin region {{xmin, xmax}, {ymin, ymax}}, the bin values lists, and metadata {m1, m2, ...} from each level in a nested list of datasets.
  • A list of built-in settings for ChartElementFunction can be obtained from ChartElementData["Histogram"].
  • The argument supplied to ColorFunction is the height for each bin.
New in 7
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team