Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • System Modeler

    Multidomain modeling and simulation of complex systems

  • Compute ServicesUse with Mathematica and Wolfram|One
  • AI AccessUse with Mathematica and Wolfram|One
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Wolfram|Alpha

  • Wolfram|Alpha Website
  • Wolfram|Alpha APIs

AI Products

  • Wolfram AI Ecosystem
  • Wolfram Foundation Tool
  • Wolfram Cloud MCP
  • Wolfram Local MCP
  • Agent One API
  • CAG Component APIs

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • Linguistic Understanding

Additional Deployment Options

  • Wolfram Cloud
  • Wolfram Web Engine
  • wolframscript
  • WSTPServer
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

Wolfram Consulting

Data Science, Finance & Business

  • Artificial Intelligence
  • Data Science
  • Healthcare
  • Real Estate

Engineering

  • Civil Engineering
  • Automotive Engineering
  • Sustainable Energy

Science & Technology

  • AgTech
  • Biosciences
  • Environmental Science
  • Food Science
  • Quantum Computation
  • Social and Behavioral Sciences

More Wolfram Solutions

Technology for Education

  • Research Universities
  • Colleges & Teaching Universities
  • High Schools
  • Resources for Students

Education Initiatives

  • Next-Gen EdTech
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
For AIs
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • System Modeler
    • Compute ServicesUse with Mathematica and Wolfram|One
    • AI AccessUse with Mathematica and Wolfram|One
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Wolfram|Alpha
      • Wolfram|Alpha Website
      • Wolfram|Alpha APIs
    • AI Products
      • Wolfram AI Ecosystem
      • Wolfram Foundation Tool
      • Wolfram Cloud MCP
      • Wolfram Local MCP
      • Agent One API
      • CAG Component APIs
    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • Linguistic Understanding
    • Additional Deployment Options
      • Wolfram Cloud
      • Wolfram Web Engine
      • wolframscript
      • WSTPServer
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions
    • Wolfram Consulting

    Data Science, Finance & Business

    • Artificial Intelligence
    • Data Science
    • Healthcare
    • Real Estate

    Engineering

    • Civil Engineering
    • Automotive Engineering
    • Sustainable Energy

    Science & Technology

    • AgTech
    • Biosciences
    • Environmental Science
    • Food Science
    • Quantum Computation
    • Social and Behavioral Sciences

    More Wolfram Solutions

    Technology for Education

    • Research Universities
    • Colleges & Teaching Universities
    • High Schools
    • Resources for Students

    Education Initiatives

    • Next-Gen EdTech
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • For AIs
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
Histogram
  • See Also
    • PairedHistogram
    • Histogram3D
    • DensityHistogram
    • HistogramList
    • SmoothHistogram
    • HistogramDistribution
    • DateHistogram
    • BinCounts
    • Tally
    • BarChart
    • ImageHistogram
    • DiscretePlot
    • PDF
  • Related Guides
    • Statistical Visualization
    • Time Series Processing
    • Numerical Data
    • Probability & Statistics with Quantities
    • Statistical Data Analysis
    • Data Visualization
    • Charting and Information Visualization
    • Tabular Visualization
    • Descriptive Statistics
    • Event Series Processing
    • Event Series Processing
    • Signal Processing
    • Random Variables
    • Using the Wolfram Data Drop
    • Reliability
    • Nonparametric Statistical Distributions
    • Signal Visualization & Analysis
    • Scientific Data Analysis
    • Tabular Processing Overview
    • Tabular Communication
    • See Also
      • PairedHistogram
      • Histogram3D
      • DensityHistogram
      • HistogramList
      • SmoothHistogram
      • HistogramDistribution
      • DateHistogram
      • BinCounts
      • Tally
      • BarChart
      • ImageHistogram
      • DiscretePlot
      • PDF
    • Related Guides
      • Statistical Visualization
      • Time Series Processing
      • Numerical Data
      • Probability & Statistics with Quantities
      • Statistical Data Analysis
      • Data Visualization
      • Charting and Information Visualization
      • Tabular Visualization
      • Descriptive Statistics
      • Event Series Processing
      • Event Series Processing
      • Signal Processing
      • Random Variables
      • Using the Wolfram Data Drop
      • Reliability
      • Nonparametric Statistical Distributions
      • Signal Visualization & Analysis
      • Scientific Data Analysis
      • Tabular Processing Overview
      • Tabular Communication

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
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Data and Layouts  
Tabular Data  
Wrappers  
Styling and Appearance  
Labeling and Legending  
Options  
AspectRatio  
Axes  
AxesLabel  
Show More Show More
AxesOrigin  
AxesStyle  
BarOrigin  
ChartElementFunction  
ChartElements  
ChartLayout  
ColorFunction  
ColorFunctionScaling  
ImageSize  
LabelingFunction  
PerformanceGoal  
PlotFit  
PlotInteractivity  
PlotLabels  
PlotLayout  
PlotLegends  
PlotRange  
PlotRangePadding  
PlotStyle  
PlotTheme  
Applications  
Properties & Relations  
Possible Issues  
Neat Examples  
See Also
Related Guides
Related Links
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • PairedHistogram
    • Histogram3D
    • DensityHistogram
    • HistogramList
    • SmoothHistogram
    • HistogramDistribution
    • DateHistogram
    • BinCounts
    • Tally
    • BarChart
    • ImageHistogram
    • DiscretePlot
    • PDF
  • Related Guides
    • Statistical Visualization
    • Time Series Processing
    • Numerical Data
    • Probability & Statistics with Quantities
    • Statistical Data Analysis
    • Data Visualization
    • Charting and Information Visualization
    • Tabular Visualization
    • Descriptive Statistics
    • Event Series Processing
    • Event Series Processing
    • Signal Processing
    • Random Variables
    • Using the Wolfram Data Drop
    • Reliability
    • Nonparametric Statistical Distributions
    • Signal Visualization & Analysis
    • Scientific Data Analysis
    • Tabular Processing Overview
    • Tabular Communication
    • See Also
      • PairedHistogram
      • Histogram3D
      • DensityHistogram
      • HistogramList
      • SmoothHistogram
      • HistogramDistribution
      • DateHistogram
      • BinCounts
      • Tally
      • BarChart
      • ImageHistogram
      • DiscretePlot
      • PDF
    • Related Guides
      • Statistical Visualization
      • Time Series Processing
      • Numerical Data
      • Probability & Statistics with Quantities
      • Statistical Data Analysis
      • Data Visualization
      • Charting and Information Visualization
      • Tabular Visualization
      • Descriptive Statistics
      • Event Series Processing
      • Event Series Processing
      • Signal Processing
      • Random Variables
      • Using the Wolfram Data Drop
      • Reliability
      • Nonparametric Statistical Distributions
      • Signal Visualization & Analysis
      • Scientific Data Analysis
      • Tabular Processing Overview
      • Tabular Communication

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:
  • xia 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
    QuantityArraythe magnitudes
    TimeSeries,EventSeries,…the values from time series data
    WeightedDatathe count for each value is its weight
    w[datai]wrapper w for dataset datai
  • Histogram[objcspec] extracts and plots values from the Tabular, TimeSeries or EventSeries object obj using the column specification cspec.
  • The following specifications cspec are allowed for plotting tabular data:
  • colhistogram values from key col
    {col1,col2,…}histogram values from keys col1,col2,…
  • The following bin width specifications bspec 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
    {"Log",bspec}apply binning bspec on log-transformed data
    fbapply 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
    fhheights 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.
  • The following wrappers can be used for chart elements:
  • Annotation[e,label]provide an annotation
    Button[e,action]define an action to execute when the element is clicked
    Callout[e,label]display the element with a callout
    EventHandler[e,…]define a general event handler for the element
    Hyperlink[e,uri]make the element act as a hyperlink
    Labeled[e,…]display the element with labeling
    Legended[e,…]include features of the element in a chart legend
    Mouseover[e,over]make the element show a mouseover form
    PopupWindow[e,cont]attach a popup window to the element
    StatusArea[e,label]display in the status area when the element is moused over
    Style[e,opts]show the element using the specified styles
    Tooltip[e,label]attach an arbitrary tooltip to the element
  • Histogram has the same options as Graphics with the following additions and changes: [List of all options]
  • AspectRatio 1/GoldenRatioratio of height to width
    Axes Truewhether to draw axes
    BarOrigin Bottomorigin of histogram bars
    ChartElementFunction Automatichow to generate raw graphics for bars
    ChartElements Automaticgraphics to use in each of the bars
    ColorFunction Automatichow to color bars
    ColorFunctionScaling Truewhether to normalize arguments to ColorFunction
    LabelingFunction Automatichow to label elements
    LegendAppearanceAutomaticoverall appearance of legends
    PerformanceGoal $PerformanceGoalaspects of performance to try to optimize
    PlotFit Nonehow to fit a curve to the histogram
    PlotFitElementsAutomaticfitted elements to show in the histogram
    PlotInteractivity $PlotInteractivitywhether to allow interactive elements
    PlotLabels Nonecategory labels for datasets
    PlotLayout Automaticoverall layout to use
    PlotLegends Nonelegends for data elements and datasets
    PlotStyle Automaticstyle for bars
    PlotTheme $PlotThemeoverall theme for the histogram
    ScalingFunctionsNonehow to scale individual coordinates
    TargetUnitsAutomaticunits to display in the chart
  • The following settings for PlotLayout can be used to display multiple sets of data:
  • "Overlapped"show all the data overlapping
    "Stacked"accumulate the data per bin
  • Possible settings for PlotLayout that show single groups of bars in multiple panels include:
  • "Column"use separate groups of bars in a column of panels
    "Row"use separate groups of bars in a row of panels
    {"Column",k},{"Row",k}use k columns or rows
    {"Column",UpTo[k]},{"Row",UpTo[k]}use at most k columns or rows
  • Typical settings for PlotLegends include:
  • Noneno legend
    Automaticautomatically determine legend
    {lbl1,lbl2,…}use lbl1, lbl2, … as legend labels
    Placed[lspec,…]specify placement for legend
  • PlotStylesty specifies the styles to use for each curve. Possible settings include:
  • {sty1,sty2,…}sequence of styles for the datasets
    <|"key"val,…|>styling elements for different levels of data
  • The accepted keys are:
  • "Base"overall style for all the datai
    "Lists"list of styles styi for each datai
  • ColorData["DefaultChartColors"] gives the default sequence of colors used by PlotStyle.
  • 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 PlotStyle, ColorFunction, Style and other wrappers, ChartElements and ChartElementFunction, with later specifications overriding earlier ones.
  • List of all options

    • AlignmentPointCenterthe default point in the graphic to align with
      AspectRatio1/GoldenRatioratio of height to width
      AxesTruewhether to draw axes
      AxesLabelNoneaxes labels
      AxesOriginAutomaticwhere axes should cross
      AxesStyle{}style specifications for the axes
      BackgroundNonebackground color for the plot
      BarOriginBottomorigin of histogram bars
      BaselinePositionAutomatichow to align with a surrounding text baseline
      BaseStyle{}base style specifications for the graphic
      ChartElementFunctionAutomatichow to generate raw graphics for bars
      ChartElementsAutomaticgraphics to use in each of the bars
      ColorFunctionAutomatichow to color bars
      ColorFunctionScalingTruewhether to normalize arguments to ColorFunction
      ContentSelectableAutomaticwhether to allow contents to be selected
      CoordinatesToolOptionsAutomaticdetailed behavior of the coordinates tool
      Epilog{}primitives rendered after the main plot
      FormatTypeTraditionalFormthe default format type for text
      FrameFalsewhether to put a frame around the plot
      FrameLabelNoneframe labels
      FrameStyle{}style specifications for the frame
      FrameTicksAutomaticframe ticks
      FrameTicksStyle{}style specifications for frame ticks
      GridLinesNonegrid lines to draw
      GridLinesStyle{}style specifications for grid lines
      ImageMargins0.the margins to leave around the graphic
      ImagePaddingAllwhat extra padding to allow for labels etc.
      ImageSizeAutomaticthe absolute size at which to render the graphic
      LabelingFunctionAutomatichow to label elements
      LabelStyle{}style specifications for labels
      LegendAppearanceAutomaticoverall appearance of legends
      MethodAutomaticdetails of graphics methods to use
      PerformanceGoal$PerformanceGoalaspects of performance to try to optimize
      PlotFitNonehow to fit a curve to the histogram
      PlotFitElementsAutomaticfitted elements to show in the histogram
      PlotInteractivity$PlotInteractivitywhether to allow interactive elements
      PlotLabelNonean overall label for the plot
      PlotLabelsNonecategory labels for datasets
      PlotLayoutAutomaticoverall layout to use
      PlotLegendsNonelegends for data elements and datasets
      PlotRangeAllrange of values to include
      PlotRangeClippingFalsewhether to clip at the plot range
      PlotRangePaddingAutomatichow much to pad the range of values
      PlotRegionAutomaticthe final display region to be filled
      PlotStyleAutomaticstyle for bars
      PlotTheme$PlotThemeoverall theme for the histogram
      PreserveImageOptionsAutomaticwhether to preserve image options when displaying new versions of the same graphic
      Prolog{}primitives rendered before the main plot
      RotateLabelTruewhether to rotate y labels on the frame
      ScalingFunctionsNonehow to scale individual coordinates
      TargetUnitsAutomaticunits to display in the chart
      TicksAutomaticaxes ticks
      TicksStyle{}style specifications for axes ticks

Examples

open all close all

Basic Examples  (4)

Generate a histogram for a list of values:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200]]

Multiple datasets:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500];
Wolfram Language code: Histogram[{data1, data2}]

Generate a probability histogram for a list of values:

Wolfram Language code: Histogram[RandomVariate[WeibullDistribution[2, 1], 1000], Automatic, "Probability"]

Show multiple datasets as a row of individual histograms:

Wolfram Language code: Histogram[{IconizedObject[«data1»], IconizedObject[«data2»]}, PlotLayout -> "Row"]

Scope  (35)

Data and Layouts  (19)

Specify the number of bins to use:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 200];
Wolfram Language code: Histogram[data, 5]

Specify the bin width:

Wolfram Language code: Histogram[data, {.5}]

The bin delimiters:

Wolfram Language code: Histogram[data, {-2, 2, 1}]

The bin delimiters as an explicit list:

Wolfram Language code: Histogram[data, {{-3, -1, 0, 1, 3}}]

Bins for discrete values are centered over the values when possible:

Wolfram Language code: Histogram[RandomInteger[10, 250]]

Use different automatic binning methods:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 1000];
Wolfram Language code: Table[Histogram[data, b, PlotLabel -> b], {b, {"Sturges", "Scott", "FreedmanDiaconis", "Wand"}}]

Use logarithmically spaced bins:

Wolfram Language code: Histogram[data, "Log"]

Delimit bins on integer boundaries using a binning function:

Wolfram Language code: integerBins[list_] := Union[IntegerPart[list]]
Wolfram Language code: integerBins[{1.2, 1.8, 2.3, 2.5}]
Wolfram Language code: Histogram[RandomReal[20, 100], integerBins]

Use different height specifications:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 200];
Wolfram Language code: Table[Histogram[data, Automatic, h, PlotLabel -> h], {h, {"Count", "Probability", "PDF", "CumulativeCount", "CDF", "SF"}}]

Use a height function that accumulates the bin counts:

Wolfram Language code: accumulatedCount[bins_, counts_] := Accumulate[counts]
Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], Automatic, accumulatedCount]

Bins associated with a dataset are styled the same:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2, data3}]

Nonreal data is taken to be missing:

Wolfram Language code: Histogram[{1, 2, 3, None, 3, 5, Missing[], 2, 1, foo, 2, 3}]
Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500];
Wolfram Language code: Histogram[{data1, None, data2}]

The data may include units:

Wolfram Language code: Histogram[{Quantity[1, "Meters"], Quantity[3, "Meters"], Quantity[2, "Meters"], Quantity[2, "Meters"], Quantity[3, "Meters"], Quantity[2, "Meters"], Quantity[5, "Meters"], Quantity[3, "Meters"], Quantity[2, "Meters"], Quantity[4, "Meters"]}, AxesLabel -> Automatic]

Specify units to use:

Wolfram Language code: Histogram[{Quantity[1, "Meters"], Quantity[3, "Meters"], Quantity[2, "Meters"], Quantity[2, "Meters"], Quantity[3, "Meters"], Quantity[2, "Meters"], Quantity[5, "Meters"], Quantity[3, "Meters"], Quantity[2, "Meters"], Quantity[4, "Meters"]}, AxesLabel -> Automatic, TargetUnits -> "Feet"]

Specify binning spec with units:

Wolfram Language code: Histogram[{Quantity[6, "Meters"], Quantity[6, "Meters"], Quantity[9, "Meters"], Quantity[2, "Meters"], Quantity[9, "Meters"], Quantity[8, "Meters"], Quantity[9, "Meters"], Quantity[5, "Meters"], Quantity[2, "Meters"], Quantity[6, "Meters"], Quantity[5, "Meters"], Quantity[10, "Meters"], Quantity[7, "Meters"], Quantity[9, "Meters"], Quantity[10, "Meters"], Quantity[3, "Meters"], Quantity[8, "Meters"], Quantity[3, "Meters"], Quantity[2, "Meters"], Quantity[1, "Meters"], Quantity[7, "Meters"], Quantity[2, "Meters"], Quantity[7, "Meters"], Quantity[5, "Meters"], Quantity[4, "Meters"]}, {Quantity[0, "Feet"], Quantity[20, "Feet"], Quantity[4, "Feet"]}, AxesLabel -> Automatic]

The values in an association are used as elements:

Wolfram Language code: Histogram[<|"a" -> 2, "b" -> 3, "c" -> 5, "d" -> 7, "e" -> 11, "f" -> 13|>, 5]

Associations can be nested:

Wolfram Language code: Histogram[<|"data one" -> <|"a" -> 6, "b" -> 3, "c" -> 5, "d" -> 7, "e" -> 11, "f" -> 13|>, "data two" -> <|"a" -> 26, "b" -> 23, "c" -> 32, "d" -> 29, "e" -> 21, "f" -> 38|>|>, 6]

Use the keys as labels:

Wolfram Language code: Histogram[<|"data one" -> {6, 3, 5, 7, 11, 13}, "data two" -> {26, 23, 32, 29, 21, 38}|>, 6, PlotLabels -> Automatic]

Use the keys as legends:

Wolfram Language code: Histogram[<|"data one" -> {6, 3, 5, 7, 11, 13}, "data two" -> {26, 23, 32, 29, 21, 38}|>, 6, PlotLegends -> Automatic]

The time stamps in TimeSeries, EventSeries, and TemporalData are ignored:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 50];
Wolfram Language code: {Histogram[data], Histogram[TimeSeries[data, {"May 24, 1982"}]]}

Weights in WeightedData affect the shape of histogram:

Wolfram Language code: data = RandomInteger[{1, 25}, 5000];
Wolfram Language code: {Histogram[data], Histogram[data, Automatic, "PDF"]}
Wolfram Language code: wd = WeightedData[data, Function@@{t, t^2}];
Wolfram Language code: {Histogram[wd], Histogram[wd, Automatic, "PDF"]}

The censoring and truncation information in EventData also affects the histogram:

Wolfram Language code: data = RandomVariate[WeibullDistribution[3, 4], 200]; t = Table[If[i > 4, 4, i], {i, data}]; c = Table[Boole[i == 4], {i, t}];
Wolfram Language code: 𝒜 = EventData[t, c]
Wolfram Language code: {Histogram[data, Automatic, "PDF"], Histogram[𝒜, Automatic, "PDF"]}

Use different layouts to display multiple datasets:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[0, 1], 500];
Wolfram Language code: Table[Histogram[{data1, data2}, PlotLabel -> l, ChartLayout -> l], {l, {"Overlapped", "Stacked"}}]

Use rows and columns of individual plots to show multiple sets:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[0, 2], 500];
Wolfram Language code: Histogram[{data1, data2}, ChartLayout -> "Row"]
Wolfram Language code: Histogram[{data1, data2}, ChartLayout -> "Column"]

Control the origin of bars:

Wolfram Language code: Table[Histogram[RandomVariate[NormalDistribution[0, 1], 200], BarOrigin -> o, PlotLabel -> o, Ticks -> None], {o, {Bottom, Left, Top, Right}}]

Tabular Data  (3)

Get tabular data:

Wolfram Language code: tabular = Tabular[ExampleData[{"Statistics", "USCars1993"}], ExampleData[{"Statistics", "USCars1993"}, "ColumnHeadings"]]

Generate a histogram for city mileage:

Wolfram Language code: Histogram[tabular -> "MPGcity"]

Create overlaid histograms for city and highway mileage:

Wolfram Language code: Histogram[tabular -> {"MPGcity", "MPGhighway"}]

Use smaller bin sizes for the data:

Wolfram Language code: Histogram[tabular -> {"MPGcity", "MPGhighway"}, {1}]

View the distributions side by side:

Wolfram Language code: Histogram[tabular -> {"MPGcity", "MPGhighway"}, {1}, ChartLayout -> "Row"]

Histogram the values for all the components in TimeSeries or EventSeries:

Wolfram Language code: Histogram[TimeSeries[TimeEventSeries`TimestampData[Association["UniformlySpacedQ" -> False, "Timestamps" -> TabularColumn[Association[ "Data" -> {363, {{NumericArray[{19723, 19724, 19725, 19726, 19727, 19728, 19729, 19730, 19731, 19732, ... ///3///////////3///f/zv/////w=="], "Capacity" -> 363, "BitCount" -> 352}] -> Missing["Unmatched"]}, "ElementType" -> TypeSpecifier["Quantity"]["NumberExpression", "DegreesCelsius"]]]}}]]]], Association[]]]

Histogram the values for a component of a TimeSeries or EventSeries:

Wolfram Language code: temps = TimeSeries[TimeEventSeries`TimestampData[Association["UniformlySpacedQ" -> False, "Timestamps" -> TabularColumn[Association[ "Data" -> {363, {{NumericArray[{19723, 19724, 19725, 19726, 19727, 19728, 19729, 19730, 19731, 19732, ... ///3///////////3///f/zv/////w=="], "Capacity" -> 363, "BitCount" -> 352}] -> Missing["Unmatched"]}, "ElementType" -> TypeSpecifier["Quantity"]["NumberExpression", "DegreesCelsius"]]]}}]]]], Association[]];
Wolfram Language code: Histogram[temps -> "Champaign"]

Histogram values from multiple components:

Wolfram Language code: Histogram[temps -> {"Oxford", "Tokyo"}, PlotLegends -> {"Oxford", "Tokyo"}]

Wrappers  (2)

Use wrappers on individual data, datasets, or collections of datasets:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: {Histogram[{data1, data2, data3}], Histogram[{data1, Style[data2, RGBColor[0.14, 0.8, 0.14]], data3}], Histogram[Style[{data1, data2, data3}, RGBColor[0.14, 0.8, 0.14]]]}

Wrappers can be nested:

Wolfram Language code: Histogram[Style[{data1, Style[data2, RGBColor[0.14, 0.8, 0.14]], data3}, RGBColor[1, 0.75, 0]]]

Override the default tooltips:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, Tooltip[data2, "my data"], data3}]

Use PopupWindow to provide additional drilldown information:

Wolfram Language code: Histogram[{data1, PopupWindow[data2, DateListPlot[FinancialData["IBM", "Jan. 1, 2004"]]], data3}]

Button can be used to trigger any action:

Wolfram Language code: Histogram[{data1, Button[data2, Speak["my data"]], data3}]

Styling and Appearance  (4)

Use an explicit list of styles for the bars:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2, data3}, PlotStyle -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.14, 0.8, 0.14], RGBColor[0.4, 0.6, 1]}]

Style can be used to override styles:

Wolfram Language code: Histogram[{data1, Style[data2, RGBColor[0.93, 0.27, 0.27]], data3}, PlotStyle -> GrayLevel[0.62]]

Use any graphic for pictorial bars:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], ChartElements -> Graphics[Disk[]]]

Use built-in, programmatically generated bars:

Wolfram Language code: ChartElementData["Histogram"]
Wolfram Language code: Table[Histogram[RandomVariate[NormalDistribution[0, 1], 200], ChartElementFunction -> f], {f, {"GlassRectangle", "GradientScaleRectangle"}}]

For detailed settings, use Palettes ▶ ChartElementSchemes:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], ChartElementFunction -> ChartElementDataFunction["SegmentScaleRectangle", "Segments" -> 7, "ColorScheme" -> "SolarColors"]]

Use a monochrome theme:

Wolfram Language code: Histogram[Table[RandomVariate[NormalDistribution[i, 0.93 ^ i], 1000], {i, {0, 3, 6, 9}}], 50, PlotTheme -> "Monochrome"]

Labeling and Legending  (7)

Use Labeled to add a label to a dataset:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2, Labeled[data3, "label", Above]}]

Use symbolic positions for label placement:

Wolfram Language code: Table[Histogram[Labeled[RandomVariate[NormalDistribution[0, 1], 500], "label", p], PlotLabel -> p], {p, {Bottom, Center, Top}}]
Wolfram Language code: Table[Histogram[Labeled[RandomVariate[NormalDistribution[0, 1], 500], "label", p], PlotLabel -> p], {p, {Left, Center, Right}}]

Provide value labels for bars by using LabelingFunction:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], LabelingFunction -> Above]

Use Placed to control placement and formatting:

Wolfram Language code: labeler[v_, {i_, j_}, {ri_, cj_}] := Placed[{CharacterRange["A", "Z"][[j]], v}, Above, Column]
Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], LabelingFunction -> labeler]

Add categorical legend entries for datasets:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2, data3}, PlotLegends -> {"ccc1", "ccc2", "ccc3"}]

Use Legended to add additional legend entries:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, Legended[Style[data2, RGBColor[0.93, 0.27, 0.27]], "extra"], data3}, PlotLegends -> {"aaa", "bbb", "ccc"}]

Use Placed to affect the positioning of legends:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Table[Histogram[{data1, data2, data3}, PlotLegends -> Placed[{"ccc1", "ccc2", "ccc3"}, p]], {p, {Below, Above}}]

Options  (89)

AspectRatio  (3)

By default, Histogram uses a fixed height to width ratio for the plot:

Wolfram Language code: Histogram[IconizedObject[«random data»]]

Make the height the same as the width with AspectRatio1:

Wolfram Language code: Histogram[IconizedObject[«random data»], AspectRatio -> 1]

AspectRatioFull adjusts the height and width to tightly fit inside other constructs:

Wolfram Language code: plot = Histogram[IconizedObject[«random data»], AspectRatio -> Full];
Wolfram Language code: {Framed[Pane[plot, {50, 100}]], Framed[Pane[plot, {100, 100}]], Framed[Pane[plot, {100, 75}]]}

Axes  (4)

By default, Axes are drawn:

Wolfram Language code: Histogram[IconizedObject[«random data»]]

Use AxesFalse to turn off axes:

Wolfram Language code: Histogram[IconizedObject[«random data»], Axes -> False]

Use AxesOrigin to specify where the axes intersect:

Wolfram Language code: Histogram[IconizedObject[«random data»], AxesOrigin -> {0, 0}]

Turn each axis on individually:

Wolfram Language code: {Histogram[IconizedObject[«random data»], Axes -> {True, False}], Histogram[IconizedObject[«random data»], Axes -> {False, True}]}

AxesLabel  (4)

No axes labels are drawn by default:

Wolfram Language code: Histogram[IconizedObject[«random data»]]

Place a label on the axis:

Wolfram Language code: Histogram[IconizedObject[«random data»], AxesLabel -> y]

Specify axes labels:

Wolfram Language code: Histogram[IconizedObject[«random data»], AxesLabel -> {x, n}]

Use units as labels:

Wolfram Language code: Histogram[QuantityArray[IconizedObject[«random data»], "Meters"], AxesLabel -> Automatic]

AxesOrigin  (2)

The position of the axes is determined automatically:

Wolfram Language code: Histogram[IconizedObject[«random data»]]

Specify an explicit origin for the axes:

Wolfram Language code: Histogram[IconizedObject[«random data»], AxesOrigin -> {3.2, 0}]

AxesStyle  (4)

Change the style for the axes:

Wolfram Language code: Histogram[IconizedObject[«random data»], AxesStyle -> RGBColor[0.93, 0.27, 0.27]]

Specify the style of each axis:

Wolfram Language code: Histogram[IconizedObject[«random data»], AxesStyle -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.4, 0.6, 1]}]

Use different styles for the ticks and the axes:

Wolfram Language code: Histogram[IconizedObject[«random data»], AxesStyle -> RGBColor[0.14, 0.8, 0.14], TicksStyle -> RGBColor[0.93, 0.27, 0.27]]

Use different styles for the labels and the axes:

Wolfram Language code: Histogram[IconizedObject[«random data»], AxesStyle -> RGBColor[0.14, 0.8, 0.14], LabelStyle -> RGBColor[0.93, 0.27, 0.27]]

BarOrigin  (1)

Change the bar origin:

Wolfram Language code: Table[Histogram[Range[5], BarOrigin -> o, PlotLabel -> o], {o, {Top, Bottom, Left, Right}}]

ChartElementFunction  (5)

Get a list of built-in settings for ChartElementFunction:

Wolfram Language code: ChartElementData["Histogram"]

For detailed settings, use Palettes ▶ ChartElementSchemes:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 200];
Wolfram Language code: Table[Histogram[data, ChartElementFunction -> f, PlotLabel -> f], {f, {"Rectangle", "GradientRectangle"}}]
Wolfram Language code: Table[Histogram[data, ChartElementFunction -> f, PlotLabel -> f], {f, {"FadingRectangle", "GlassRectangle"}}]

ChartElementFunction is appropriate to show the global scale:

Wolfram Language code: Table[Histogram[data, ChartElementFunction -> f, PlotLabel -> f], {f, {"GradientScaleRectangle", "SegmentScaleRectangle"}}]

Write a custom ChartElementFunction:

Wolfram Language code: f[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Rectangle[{xmin, ymin}, {xmax, ymax}]
Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], ChartElementFunction -> f]
Wolfram Language code: g[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Polygon[{{xmin, ymin}, {xmax, ymax}, {xmin, ymax}, {xmax, ymin}}]
Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], ChartElementFunction -> g]

Use metadata passed on from the input, in this case charting the data:

Wolfram Language code: DataDrilldownBar[{{xmin_, xmax_}, {ymin_, ymax_}}, data_, {True}, ___] := PopupWindow[Polygon[{{xmin, ymin}, {xmax, ymax}, {xmin, ymax}, {xmax, ymin}}], PieChart[data]]
Wolfram Language code: DataDrilldownBar[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Rectangle[{xmin, ymin}, {xmax, ymax}]
Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2 -> True, data3}, ChartElementFunction -> DataDrilldownBar]

Built-in element functions may have options; use Palettes ▶ ChartElementSchemes to set them:

Wolfram Language code: ChartElementData["Rectangle", "Options"]
Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 500];
Wolfram Language code: Table[Histogram[data, ChartElementFunction -> ChartElementData["Rectangle", "RoundingRadius" -> r], PlotLabel -> r], {r, {0, 3, 6}}]

ChartElements  (9)

Create a pictorial chart based on any Graphics object:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], ChartElements -> Graphics[Disk[]]]

Graphics3D:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 50], ChartElements -> Graphics3D[Sphere[]]]

Image:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 50], ChartElements -> ExampleData[{"TestImage", "House"}]]

Use a stretched version of the graphic:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], ChartElements -> {[image], All}]

Use explicit sizes for width and height:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 100];
Wolfram Language code: Table[Histogram[data, ChartElements -> {Graphics[Disk[], AspectRatio -> Full], s}, PlotLabel -> s], {s, {{1 / 2, 5}, {1, 3}}}]

Using All for width or height causes that direction to stretch to the full size of the bar:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 100];
Wolfram Language code: Table[Histogram[data, ChartElements -> {[image], s}, PlotLabel -> s], {s, {{1 / 2, All}, {All, 20}}}]

Use a different graphic for each row of data:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2, data3}, ChartElements -> {[image], [image], [image]}]

Graphics are used cyclically:

Wolfram Language code: Histogram[{data1, data2, data3}, ChartElements -> {{[image], [image]}, None}]

Styles are inherited from styles set through PlotStyle etc:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], ChartElements -> [image], PlotStyle -> RGBColor[0.14, 0.8, 0.14]]

Style can override the settings from PlotStyle:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, Style[data2, GrayLevel[0]], data3}, ChartElements -> [image], PlotStyle -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.14, 0.8, 0.14], RGBColor[0.4, 0.6, 1]}]

Explicit styles set in the graphic will override other style settings:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], ChartElements -> [image], PlotStyle -> RGBColor[0.14, 0.8, 0.14]]

Create true 3D-shaded bars:

Wolfram Language code: g = Graphics3D[{EdgeForm[], Specularity[White, 30], Cylinder[]}, ViewPoint -> {0, -Infinity, 0}, Boxed -> False, Lighting -> "Neutral", PlotRangePadding -> 0];
Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], ChartElements -> {g, All}, PlotStyle -> RGBColor[0.8, 0.3, 0.8]]

ChartLayout  (5)

Use different layouts to display multiple datasets:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[0, 1], 500];
Wolfram Language code: Table[Histogram[{data1, data2}, ChartLayout -> l, PlotLabel -> l], {l, {"Overlapped", "Stacked"}}]

With multiple datasets that are fairly disjoint, typically "Overlapped" works better:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1], 500];
Wolfram Language code: Table[Histogram[{data1, data2}, ChartLayout -> l, PlotLabel -> l], {l, {"Overlapped", "Stacked"}}]

Place each group of bars in a separate panel using shared axes:

Wolfram Language code: Histogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»]}, ChartLayout -> Column]

Use a row instead of a column:

Wolfram Language code: Histogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»]}, ImageSize -> Medium, ChartLayout -> Row]

Use multiple columns or rows:

Wolfram Language code: Histogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»], IconizedObject[«σ = 3»], IconizedObject[«σ = 4»]}, ImageSize -> Medium, ChartLayout -> {"Column", 2}]

Prefer full columns or rows:

Wolfram Language code: Histogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»], IconizedObject[«σ = 3»], IconizedObject[«σ = 4»], IconizedObject[«σ = 5»], IconizedObject[«σ = 6»]}, ImageSize -> Medium, ChartLayout -> {"Column", UpTo[4]}]
Wolfram Language code: Histogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»], IconizedObject[«σ = 3»], IconizedObject[«σ = 4»], IconizedObject[«σ = 5»], IconizedObject[«σ = 6»]}, ImageSize -> Medium, ChartLayout -> {"Column", 4}]

ColorFunction  (4)

Color by bar height:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], ColorFunction -> Function[{height}, ColorData["Rainbow"][height]]]

Use ColorFunctionScaling->False to get unscaled height values:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], ColorFunction -> (Which[# < 40, RGBColor[1, 0.75, 0], 40 ≤ # < 90, RGBColor[0.98, 0.56, 0.17], True, RGBColor[0.93, 0.27, 0.27]]&), ColorFunctionScaling -> False]

ColorFunction overrides styles in PlotStyle:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], PlotStyle -> RGBColor[0.93, 0.27, 0.27], ColorFunction -> "Pastel"]

Use ColorFunction to combine different style effects:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], ColorFunction -> Function[{height}, Opacity[height]], PlotStyle -> RGBColor[0.8, 0.3, 0.8]]

ColorFunctionScaling  (2)

By default, scaled height values are used:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], ColorFunction -> Function[{height}, ColorData["Rainbow"][height]]]

Use ColorFunctionScaling->False to get unscaled height values:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], ColorFunction -> (Which[# < 40, RGBColor[1, 0.75, 0], 40 ≤ # < 90, RGBColor[0.98, 0.56, 0.17], True, RGBColor[0.93, 0.27, 0.27]]&), ColorFunctionScaling -> False]

ImageSize  (7)

Use named sizes such as Tiny, Small, Medium and Large:

Wolfram Language code: {Histogram[IconizedObject[«data»], ImageSize -> Tiny], Histogram[IconizedObject[«data»], ImageSize -> Small]}

Specify the width of the plot:

Wolfram Language code: {Histogram[IconizedObject[«data»], ImageSize -> 150], Histogram[IconizedObject[«data»], AspectRatio -> 1.5, ImageSize -> 150]}

Specify the height of the plot:

Wolfram Language code: {Histogram[IconizedObject[«data»], ImageSize -> {Automatic, 150}], Histogram[IconizedObject[«data»], AspectRatio -> 2, ImageSize -> {Automatic, 150}]}

Allow the width and height to be up to a certain size:

Wolfram Language code: {Histogram[IconizedObject[«data»], ImageSize -> UpTo[200]], Histogram[IconizedObject[«data»], AspectRatio -> 1 / 2, ImageSize -> UpTo[200]]}

Specify the width and height for a graphic, padding with space if necessary:

Wolfram Language code: Histogram[IconizedObject[«data»], ImageSize -> {200, 200}, Background -> GrayLevel[0.62]]

Setting AspectRatioFull will fill the available space:

Wolfram Language code: Histogram[IconizedObject[«data»], AspectRatio -> Full, ImageSize -> {200, 200}, Background -> GrayLevel[0.62]]

Use maximum sizes for the width and height:

Wolfram Language code: {Histogram[IconizedObject[«data»], ImageSize -> {UpTo[150], UpTo[100]}], Histogram[IconizedObject[«data»], AspectRatio -> 2, ImageSize -> {UpTo[150], UpTo[100]}]}

Use ImageSizeFull to fill the available space in an object:

Wolfram Language code: Framed[Pane[Histogram[IconizedObject[«data»], AspectRatio -> Full, ImageSize -> Full, Background -> GrayLevel[0.62]], {200, 100}]]

Specify the image size as a fraction of the available space:

Wolfram Language code: Framed[Pane[Histogram[IconizedObject[«data»], AspectRatio -> Full, ImageSize -> {Scaled[0.5], Scaled[0.5]}, Background -> GrayLevel[0.62]], {200, 100}]]

LabelingFunction  (7)

Use automatic labeling by values through Tooltip and StatusArea:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], LabelingFunction -> Automatic]

Do no labeling:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], LabelingFunction -> None]

Use symbolic positions to control label placement:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], 8, LabelingFunction -> Above, Ticks -> None]
Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], 8, LabelingFunction -> After, BarOrigin -> Left, Ticks -> None]

Coordinate-based placement relative to a bar:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], 8, LabelingFunction -> {0.5, 1.2}, Ticks -> None]

Control the formatting of labels:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], 8, LabelingFunction -> (Placed[Row[{"$", #}], Above]&)]

Use the dataset position index to generate the label:

Wolfram Language code: labeler[v_, {i_, j_}, {ri_, cj_}] := Placed[{CharacterRange["A", "Z"][[j]], v}, Above, Column]
Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], LabelingFunction -> labeler, ImageSize -> Medium]

Use the given chart labels as arguments to the labeling function:

Wolfram Language code: labeler[v_, {i_, j_}, {ri_, cj_}] := Placed[Join[ri, cj, {v}], Above, Column]
Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], PlotLabels -> <|"Elements" -> Placed[CharacterRange["A", "Z"], None]|>, LabelingFunction -> labeler, ImageSize -> Medium]

PerformanceGoal  (1)

Generate a bar chart with interactive highlighting:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 500];
Wolfram Language code: Histogram[data, PerformanceGoal -> "Quality"]

Emphasize performance by disabling interactive behaviors:

Wolfram Language code: Histogram[data, PerformanceGoal -> "Speed"]

Typically, less memory is required for non-interactive charts:

Wolfram Language code: Table[ByteCount@Histogram[data, PerformanceGoal -> p], {p, {"Quality", "Speed"}}]

PlotFit  (3)

Automatically fit a model to the data:

Wolfram Language code: Histogram[IconizedObject[«data»], PlotFit -> Automatic]

Fit a quadratic curve to the data:

Wolfram Language code: Histogram[IconizedObject[«data»], PlotFit -> "Quadratic"]

Use FormulaModel to approximate the data with a bell curve:

Wolfram Language code: Histogram[IconizedObject[«data»], Automatic, "PDF", PlotFit -> FormulaModel[E^-((-a + x)^2/2 b^2) / (b Sqrt[2 π]), {a, b}, x]]

PlotInteractivity  (4)

Histograms with a moderate number of bars automatically have tooltips and mouseover effects:

Wolfram Language code: Histogram[IconizedObject[«data»]]

Turn off all the interactive elements:

Wolfram Language code: Histogram[IconizedObject[«data»], PlotInteractivity -> False]

Interactive elements provided as part of the input are disabled:

Wolfram Language code: Histogram[{IconizedObject[«Subscript[data, 1]»], Tooltip[IconizedObject[«Subscript[data, 2]»], "hello"]}, PlotInteractivity -> False]

Allow provided interactive elements and disable automatic ones:

Wolfram Language code: Histogram[{IconizedObject[«Subscript[data, 1]»], Tooltip[IconizedObject[«Subscript[data, 2]»], "hello"]}, PlotInteractivity -> <|"User" -> True, "System" -> False|>]

PlotLabels  (6)

Place dataset labels above each histogram:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2, data3}, PlotLabels -> Placed[{"a", "b", "c"}, Above], PlotRange -> All]

Labeled wrappers around datasets will place additional labels:

Wolfram Language code: Histogram[{data1, Labeled[data2, "label", Center], data3}, PlotLabels -> Placed[{"a", "b", "c"}, Above]]
Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];

Use Placed to control label placement:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 500];
Wolfram Language code: Table[Histogram[data, PlotLabels -> Placed[{"label"}, p], PlotLabel -> p], {p, {Bottom, Center, Top}}]

Symbolic positions outside the bar:

Wolfram Language code: {Histogram[data, Ticks -> None, PlotLabels -> Placed[{"label"}, Below], BarOrigin -> Top], Histogram[data, Ticks -> None, PlotLabels -> Placed[{"label"}, Above], BarOrigin -> Bottom]}
Wolfram Language code: {Histogram[data, Ticks -> None, PlotLabels -> Placed[{"label"}, Before], BarOrigin -> Right], Histogram[data, Ticks -> None, PlotLabels -> Placed[{"label"}, After], BarOrigin -> Left]}

Coordinate-based placement relative to a histogram:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 500];
Wolfram Language code: Table[Histogram[data, PlotLabels -> Placed[{"label"}, p], Ticks -> None, PlotLabel -> p], {p, {{0, 0}, {0.5, 0.5}, {1, 1}}}]

Place all labels at the lower-left corner and vary the coordinates within the label:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 500];
Wolfram Language code: Table[Histogram[data, PlotLabels -> Placed[{Framed["label"]}, {{0, 0}, p}], Ticks -> None, PlotLabel -> p], {p, {{0, 0}, {0.5, 0.5}, {1, 1}}}]

Use the third argument to Placed to control formatting:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], PlotLabels -> Placed[{"label"}, Center, Rotate[#, 45Degree]&], Ticks -> None]
Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], PlotLabels -> Placed[{"aaa"}, Center, Framed[#, FrameMargins -> 1, Background -> RGBColor[1, 0.75, 0]]&]]

Use a named formatting function:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], PlotLabels -> Placed[{"aaa"}, Center, "Framed"]]

Use a hyperlink label:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], PlotLabels -> Placed[{"aaa"}, Center, Hyperlink[#, "http://www.wolfram.com"]&]]

Place multiple labels:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], PlotLabels -> Placed[{{"aaa"}, {"zzz"}}, {Top, Bottom}]]

PlotLayout  (4)

By default, histograms for different datasets overlap:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1], 500];
Wolfram Language code: Histogram[{data1, data2}]

Stack the histograms to show total counts:

Wolfram Language code: Histogram[{data1, data2}, PlotLayout -> "Stacked"]

Place each group of bars in a separate panel using shared axes:

Wolfram Language code: Histogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»]}, PlotLayout -> Column]

Use a row instead of a column:

Wolfram Language code: Histogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»]}, ImageSize -> Medium, PlotLayout -> Row]

Use multiple columns or rows:

Wolfram Language code: Histogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»], IconizedObject[«σ = 3»], IconizedObject[«σ = 4»]}, ImageSize -> Medium, PlotLayout -> {"Column", 2}]

Prefer full columns or rows:

Wolfram Language code: Histogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»], IconizedObject[«σ = 3»], IconizedObject[«σ = 4»], IconizedObject[«σ = 5»], IconizedObject[«σ = 6»]}, ImageSize -> Medium, PlotLayout -> {"Column", UpTo[4]}]
Wolfram Language code: Histogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»], IconizedObject[«σ = 3»], IconizedObject[«σ = 4»], IconizedObject[«σ = 5»], IconizedObject[«σ = 6»]}, ImageSize -> Medium, PlotLayout -> {"Column", 4}]

PlotLegends  (3)

Generate a legend based on the plot style:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2, data3}, PlotLegends -> {"John", "Mary", "Bob"}]

Use Placed to control the placement of legends:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2, data3}, PlotLegends -> Placed[{"ccc1", "ccc2", "ccc3"}, Below]]

Place the legend inside the plot:

Wolfram Language code: Histogram[{data1, data2, data3}, PlotLegends -> Placed[{"ccc1", "ccc2", "ccc3"}, {Left, Top}]]

Use SwatchLegend to control the legend appearance:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2, data3}, PlotLegends -> SwatchLegend[Automatic, {"ccc1", "ccc2", "ccc3"}, LegendFunction -> Framed]]

PlotRange  (1)

PlotRange is automatically calculated:

Wolfram Language code: Histogram[Table[i + 100 KroneckerDelta[i - 5] + 50KroneckerDelta[i - 10], {i, 40}]]

Show all bins:

Wolfram Language code: Histogram[Table[i + 100 KroneckerDelta[i - 5] + 50KroneckerDelta[i - 10], {i, 40}], PlotRange -> All]

PlotRangePadding  (3)

Specify a single plot range padding for all directions:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 500];
Wolfram Language code: Table[Histogram[data, Axes -> None, Frame -> True, PlotLabel -> ToString@p, PlotRangePadding -> p], {p, {Automatic, None, 2, Scaled[0.15]}}]

Specify a separate plot range padding for horizontal and vertical directions:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 500];
Wolfram Language code: Table[Histogram[data, Axes -> None, Frame -> True, PlotLabel -> ToString@p, PlotRangePadding -> p], {p, {{2, Automatic}, {Automatic, 30}, {Scaled[0.15], Automatic}, {Automatic, Scaled[0.15]}}}]

Specify a separate plot range padding for each direction:

Wolfram Language code: data = RandomVariate[NormalDistribution[0, 1], 500];
Wolfram Language code: Table[Histogram[data, Axes -> None, Frame -> True, PlotLabel -> ToString@p, PlotRangePadding -> p], {p, {{{1, 3}, Automatic}, {Automatic, {10, 30}}, {{1, 3}, {10, 30}}}}]

PlotStyle  (5)

Use PlotStyle to style bars:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], PlotStyle -> RGBColor[0.4, 0.6, 1]]

Give a list of styles for multiple datasets:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2, data3}, PlotStyle -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.98, 0.56, 0.17], RGBColor[1, 0.75, 0]}]

Use the association-based syntax to set a base style for all data:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, data2, data3}, PlotStyle -> <|"Base" -> Opacity[1]|>]

Use a different style for each of the datasets:

Wolfram Language code: Histogram[{data1, data2, data3}, PlotStyle -> <|"Lists" -> {RGBColor[0, 0.35, 0], RGBColor[0.07, 0.25, 0.6], RGBColor[0.42, 0.03, 0.42]}|>]

Provide an overall base style as well as styles for each dataset:

Wolfram Language code: Histogram[{data1, data2, data3}, PlotStyle -> <|"Base" -> EdgeForm[GrayLevel[1]], "Lists" -> {RGBColor[0, 0.35, 0], RGBColor[0.07, 0.25, 0.6], RGBColor[0.42, 0.03, 0.42]}|>]

Style overrides settings for PlotStyle:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 500]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];
Wolfram Language code: Histogram[{data1, Style[data2, RGBColor[0.14, 0.8, 0.14]], data3}, PlotStyle -> GrayLevel[0.62]]

ColorFunction overrides settings for PlotStyle:

Wolfram Language code: Histogram[data1, PlotStyle -> GrayLevel[0.62], ColorFunction -> "SolarColors"]

ChartElements may override settings for PlotStyle:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 500], ChartElements -> [image], PlotStyle -> RGBColor[0.4, 0.6, 1]]

PlotTheme  (2)

Use a theme with simple ticks and grid lines in a high-contrast color scheme:

Wolfram Language code: Histogram[Table[RandomVariate[NormalDistribution[i, 0.95 ^ i], 500], {i, {0, 3, 6}}], 50, PlotTheme -> "Marketing"]

Change the color scheme:

Wolfram Language code: Histogram[Table[RandomVariate[NormalDistribution[i, 0.95 ^ i], 500], {i, {0, 3, 6}}], 50, PlotTheme -> "Marketing", PlotStyle -> <|"Base" -> Opacity[1], "Lists" -> {RGBColor[0.23780781740448254, 0.6887454706969063, 1.], RGBColor[1., 0.519599248047801, 0.3096774660909407], RGBColor[0., 0.7904116386138192, 0.7051174262187454]}|>]

Applications  (13)

Overlay a plot of the PDF for a normal distribution:

Wolfram Language code: Show[Histogram[RandomVariate[NormalDistribution[0, 1], 1500], Automatic, "PDF"], Plot[PDF[NormalDistribution[0, 1], x], {x, -4, 4}, PlotStyle -> RGBColor[0.93, 0.27, 0.27]]]

Number of elements discovered each decade from 1700 to 2000:

Wolfram Language code: Histogram[Table[ElementData[en, "DiscoveryYear"]["Year"], {en, ElementData[]}], {1700, 2000, 10}]

Distribution of lengths of human chromosomes:

Wolfram Language code: Histogram[ Table[GenomeData[i, "SequenceLength"], {i, 41}], "Log" ]

Create a ListLinePlot using counts extracted from a histogram:

Wolfram Language code: {g, {binCounts}} = Reap[Histogram[RandomVariate[NormalDistribution[0, 1], 100], {-2, 2, 0.25}, Function[{bins, counts}, Sow[counts]]]];
Wolfram Language code: {g, ListLinePlot[binCounts]}

Click a dataset in the histogram to hear an acoustic representation of the counts:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 200]; data2 = RandomVariate[WeibullDistribution[2, 1], 200];
Wolfram Language code: accousticCounts[counts_, style_] := EmitSound[Sound[Table[SoundNote[Round[c], 3 / Length[counts], style], {c, counts}]]]
Wolfram Language code: allCounts = {}; Histogram[{Button[data1, accousticCounts[allCounts[[1]], "Piano"]], Button[data2, accousticCounts[allCounts[[2]], "Tuba"]]}, 18, Function[{bins, counts}, AppendTo[allCounts, 20 counts / Total[counts]];counts]]

Click the bars to hear the counts in the corresponding bin:

Wolfram Language code: speakBar[{{xmin_, xmax_}, {ymin_, ymax_}}, data_, ___] := Button[Rectangle[{xmin, ymin}, {xmax, ymax}], Speak[data]]
Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200], ChartElementFunction -> speakBar]

Create a matrix of handwritten digits using Graphics ▶ Drawing Tools:

Wolfram Language code: data = | | | | | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | | [image] | [image] | [image] | | [image] | [image] | [image] | | [image] | [image] | [image] |;

Compute the histogram of line angles used in a character drawing:

Wolfram Language code: heights[bins_, {ca_, c__, cz_}] := {ca + cz, c, 0}
Wolfram Language code: LineAngleHistogram[g_, o : OptionsPattern[]] := Module[{angles = Flatten@Cases[g, Line[d_] :> (ArcTan@@(#2 - #1)&)@@@Partition[d, 2, {1}], ∞]}, Histogram[angles, {-(9π/8), (9π/8), (π/4)}, heights, PlotRange -> All, Ticks -> {None, Automatic}, PlotLabels -> <|"Elements" -> Placed[{[image], [image], [image], [image], [image], [image], [image], [image]}, Below]|>, o]]

Create histograms for each digit showing the frequency of line angles:

Wolfram Language code: Grid@Table[LineAngleHistogram[data[[j, k]], ImageSize -> 170, PlotLabel -> data[[j, k]]], {j, 1, 3}, {k, 1, 3}]

Create a stacked histogram of male and female life expectancy for all countries:

Wolfram Language code: data = Table[CountryData[#, p]& /@ CountryData[], {p, {"MaleLifeExpectancy", "FemaleLifeExpectancy"}}];
Wolfram Language code: Histogram[data, {5}, ChartLayout -> "Stacked", PlotStyle -> {RGBColor[0.855879, 0.665019, 0.302953], RGBColor[0.780926, 0.753979, 0.604883]}, PlotLabel -> Style["World Life Expectancy", "Title", 14], PlotLegends -> {"Male", "Female"}, AxesLabel -> {"Age", "Number of Countries"}]

Select a subset of languages available in DictionaryLookup:

Wolfram Language code: DictionaryLookup[All]
Wolfram Language code: languages = {"Arabic", "English", "French", "Esperanto", "Faroese", "German", "Hebrew", "Hindi", "Latin", "Russian", "Spanish", "Swedish"};

Mouse over the bars to get the word counts with a particular string length:

Wolfram Language code: GraphicsGrid[Partition[Table[Histogram[StringLength /@ DictionaryLookup[{l, All}], {1, 25, 1}, PlotLabel -> l, PlotRange -> {{0, 25}, All}], {l, languages}], 3], ImageSize -> 500]

Power spectrum of the Thue–Morse nested sequence [more info]:

Wolfram Language code: data = Abs[Fourier[Nest[Flatten[# /. {1 -> {1, 0}, 0 -> {0, 1}}]&, {1}, 7]]];
Wolfram Language code: ListLinePlot[data]

Distribution of frequencies:

Wolfram Language code: Histogram[data, 20, "LogCount", LabelingFunction -> Above, PlotRange -> All]

Create a cumulative histogram:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 200]; data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500]; options = {PlotLegends -> <|"Lists" -> Placed[{"Series A", "Series B"}, Above]|>, AxesLabel -> {"Value intervals", "Cumulative frequency"}};
Wolfram Language code: accumulatedCount[bins_, counts_] := Accumulate[counts]
Wolfram Language code: Histogram[{data1, data2}, Automatic, accumulatedCount, options]

Create a stacked cumulative histogram:

Wolfram Language code: Histogram[{data1, data2}, Automatic, accumulatedCount, options, ChartLayout -> "Stacked"]

Wind direction from WeatherData ranges from 0° to 360°:

Wolfram Language code: WeatherData["KCMI", "WindDirection"]
Wolfram Language code: WeatherData["KCMI", "WindDirection", "Units"]

Get wind direction data for Willard Airport (CMI) at Champaign, Illinois:

Wolfram Language code: data = WeatherData["KCMI", "WindDirection", {{2007, 11, 1}, {2008, 11, 1}}];

Define a chart element function that stores bin width and count data using Sow:

Wolfram Language code: sowingBar[{{x0_, x1_}, {y0_, y1_}}, __] := (Sow[{x1 - x0, 100 * (y1 - y0)}];Rectangle[{x0, y0}, {x1, y1}])

Create a histogram of the wind directions, and store the bin width and frequencies:

Wolfram Language code: {histogram, newdata} = Reap[Histogram[data, Automatic, "Probability", ChartElementFunction -> sowingBar]];
Wolfram Language code: histogram

Create a polar histogram of the wind-direction frequencies:

Wolfram Language code: SectorChart[newdata, SectorOrigin -> {Pi / 2, "Clockwise"}, PolarAxes -> True, PolarGridLines -> Automatic, PolarTicks -> {"Direction", Automatic}, PlotStyle -> <|"Base" -> Directive[Opacity[1], EdgeForm[Thin]]|>, ColorFunction -> Function[{c, r}, ColorData["RedBlueTones"][1 - r]]]

Histogram for the slice distribution of a random process:

Wolfram Language code: data = RandomVariate[WienerProcess[3, 4][7], 10 ^ 4];
Wolfram Language code: Histogram[data, 20, "PDF"]

Histogram for several slices of a process:

Wolfram Language code: {data1, data2, data3} = Table[RandomVariate[WienerProcess[3, 4][t], 10 ^ 4], {t, {1, 3, 7}}];
Wolfram Language code: Histogram[{data1, data2, data3}, PlotLegends -> {"t=1", "t=3", "t=7"}]

Properties & Relations  (3)

Histogram automatically determines bins to use based on data:

Wolfram Language code: Histogram[RandomVariate[NormalDistribution[0, 1], 200]]

Use BinCounts for explicit binning of data:

Wolfram Language code: BinCounts[RandomVariate[NormalDistribution[0, 1], 200], {-3, 3, .5}]

Display using BarChart:

Wolfram Language code: BarChart[%, BarSpacing -> 0]

Use PDF to get a parametric probability density function:

Wolfram Language code: PDF[NormalDistribution[2, 1], x]
Wolfram Language code: Plot[%, {x, -1, 5}]

Show together with Histogram of random data:

Wolfram Language code: Show[Histogram[RandomVariate[NormalDistribution[2, 1], 500], Automatic, "PDF"], %]

Possible Issues  (2)

Discrete values that don't align with the bin width can result in gaps:

Wolfram Language code: Histogram[Range[0, 99, 3], {2}]

Bins include the left endpoint but not the right, which can result in unexpected bins:

Wolfram Language code: data = Range[0, 1, 0.01];
Wolfram Language code: Histogram[data]

The value 1 is not included in this histogram because it would be in the bin :

Wolfram Language code: Histogram[data, {0, 1, 0.2}]

Neat Examples  (1)

Overlay several PDF plots for Poisson distributions:

Wolfram Language code: Show[Histogram[Table[RandomInteger[PoissonDistribution[10 i], 1000], {i, 5}], {1}, "PDF", PlotStyle -> ColorData[98, "ColorList"], PlotRange -> All], Plot[Evaluate[Table[PDF[PoissonDistribution[10 μ], x], {μ, 5}]], {x, 0, 80}, PlotStyle -> ColorData[98, "ColorList"], PlotRange -> All]]

See Also

PairedHistogram  Histogram3D  DensityHistogram  HistogramList  SmoothHistogram  HistogramDistribution  DateHistogram  BinCounts  Tally  BarChart  ImageHistogram  DiscretePlot  PDF

Related Guides

    ▪
  • Statistical Visualization
  • ▪
  • Time Series Processing
  • ▪
  • Numerical Data
  • ▪
  • Probability & Statistics with Quantities
  • ▪
  • Statistical Data Analysis
  • ▪
  • Data Visualization
  • ▪
  • Charting and Information Visualization
  • ▪
  • Tabular Visualization
  • ▪
  • Descriptive Statistics
  • ▪
  • Event Series Processing
  • ▪
  • Event Series Processing
  • ▪
  • Signal Processing
  • ▪
  • Random Variables
  • ▪
  • Using the Wolfram Data Drop
  • ▪
  • Reliability
  • ▪
  • Nonparametric Statistical Distributions
  • ▪
  • Signal Visualization & Analysis
  • ▪
  • Scientific Data Analysis
  • ▪
  • Tabular Processing Overview
  • ▪
  • Tabular Communication

Related Links

  • An Elementary Introduction to the Wolfram Language : More Forms of Visualization

History

Introduced in 2008 (7.0) | Updated in 2010 (8.0) ▪ 2012 (9.0) ▪ 2014 (10.0) ▪ 2015 (10.2) ▪ 2021 (13.0) ▪ 2025 (14.2) ▪ 2025 (14.3) ▪ 2026 (15.0)

Wolfram Research (2008), Histogram, Wolfram Language function, https://reference.wolfram.com/language/ref/Histogram.html (updated 2026).

Text

Wolfram Research (2008), Histogram, Wolfram Language function, https://reference.wolfram.com/language/ref/Histogram.html (updated 2026).

CMS

Wolfram Language. 2008. "Histogram." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/Histogram.html.

APA

Wolfram Language. (2008). Histogram. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Histogram.html

BibTeX

@misc{reference.wolfram_2026_histogram, author="Wolfram Research", title="{Histogram}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/Histogram.html}", note=[Accessed: 01-September-2026]}

BibLaTeX

@online{reference.wolfram_2026_histogram, organization={Wolfram Research}, title={Histogram}, year={2026}, url={https://reference.wolfram.com/language/ref/Histogram.html}, note=[Accessed: 01-September-2026]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • AI Access
  • Compute Services
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Engine
  • Wolfram Player

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2026 Wolfram
© 2026 Wolfram | Legal & Privacy Policy |
English