Histogram

Histogram[{x1,x2,}]

plots a histogram of the values xi.

Histogram[{x1,x2,},bspec]

plots a histogram with bin width specification bspec.

Histogram[{x1,x2,},bspec,hspec]

plots a histogram with bin heights computed according to the specification hspec.

Histogram[{data1,data2,},]

plots histograms for multiple datasets datai.

Details and Options

• Histogram[data] by default plots a histogram with equal bin widths chosen to approximate an assumed underlying smooth distribution of the values xi.
• Data values xi can be given in the following forms:
•  xi a number Quantity[xi,unit] a number with a unit
• Datasets datai have the following forms and interpretations:
•  {x1,x2,…} a list of values xi <|k1x1,k2x2,…|> the values xi from the association QuantityArray the magnitudes TimeSeries,EventSeries,… the values from time series data WeightedData the count for each value is its weight w[datai] wrapper w for dataset datai
• The following bin width specifications bspec can be given:
•  n use 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),… Automatic determine bin widths automatically "name" use a named binning method {"Log",bspec} apply binning bspec on log-transformed data fb apply fb to get an explicit bin specification {b1,b2,…}
• The binning specification "Log" is taken to use the Automatic underlying binning method.
• 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 "Knuth" balance likelihood and prior probability of a piecewise uniform model "Wand" one-level recursive approximate Wand binning
• The function fb in Histogram[data,fb] 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,bspec,hspec]. The following forms can be used:
•  "Count" number of elements in each bin "CumulativeCount" cumulative counts "SurvivalCount" survival counts "Probability" fraction of values lying in each bin "Intensity" count divided by bin width "PDF" probability density function "CDF" cumulative distribution function "SF" survival function "HF" hazard function "CHF" cumulative hazard function {"Log",hspec} log-transformed height specification fh heights obtained by applying fh to bins and counts
• The function fh in Histogram[data,bspec,fh] is applied to two arguments: a list of bins {{b1,b2},{b2,b3},}, and a 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.
• Possible symbolic wrappers are the same as for BarChart, and include Style, Labeled, Legended, etc.
• Histogram has the same options as Graphics with the following additions and changes:
•  AspectRatio 1/GoldenRatio overall ratio of width to height Axes True whether to draw axes BarOrigin Bottom origin of histogram bars ChartBaseStyle Automatic overall style for bars ChartElementFunction Automatic how to generate raw graphics for bars ChartElements Automatic graphics to use in each of the bars ChartLabels None category labels for datasets ChartLayout Automatic overall layout to use ChartLegends None legends for data elements and datasets ChartStyle Automatic style for bars ColorFunction Automatic how to color bars ColorFunctionScaling True whether to normalize arguments to ColorFunction LabelingFunction Automatic how to label elements LegendAppearance Automatic overall appearance of legends PerformanceGoal \$PerformanceGoal aspects of performance to try to optimize PlotTheme \$PlotTheme overall theme for the histogram ScalingFunctions None how to scale individual coordinates TargetUnits Automatic units to display in the chart
• 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.
• With ScalingFunctions->{sx,sy}, the coordinate is scaled using sx etc.
• Style and other specifications from options and other constructs in BarChart are effectively applied in the order ChartStyle, ColorFunction, Style and other wrappers, ChartElements, and ChartElementFunction, with later specifications overriding earlier ones.

Examples

open allclose all

Basic Examples(4)

Generate a histogram for a list of values:

 In[1]:=
 Out[1]=

Multiple datasets:

 In[1]:=
 In[2]:=
 Out[2]=

Generate a probability histogram for a list of values:

 In[1]:=
 Out[1]=

Pictorial bars:

 In[1]:=
 Out[1]=

Use procedural bars:

 In[2]:=
 Out[2]=