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

Examples

open allclose all

Basic Examples  (4)

Generate a histogram for a list of values:

Multiple datasets:

Generate a probability histogram for a list of values:

Show multiple datasets as a row of individual histograms:

Scope  (32)

Data and Layouts  (19)

Specify the number of bins to use:

Specify the bin width:

The bin delimiters:

The bin delimiters as an explicit list:

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

Use different automatic binning methods:

Use logarithmically spaced bins:

Delimit bins on integer boundaries using a binning function:

Use different height specifications:

Use a height function that accumulates the bin counts:

Bins associated with a dataset are styled the same:

Nonreal data is taken to be missing:

The data may include units:

Specify units to use:

Specify binning spec with units:

The values in an association are used as elements:

Associations can be nested:

Use the keys as labels:

Use the keys as legends:

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

Weights in WeightedData affect the shape of histogram:

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

Use different layouts to display multiple datasets:

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

Control the origin of bars:

Wrappers  (2)

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

Wrappers can be nested:

Override the default tooltips:

Use PopupWindow to provide additional drilldown information:

Button can be used to trigger any action:

Styling and Appearance  (4)

Use an explicit list of styles for the bars:

Use any gradient or indexed color schemes from ColorData:

ChartBaseStyle can be used to set an initial style for all chart elements:

Style can be used to override styles:

Use any graphic for pictorial bars:

Use built-in, programmatically generated bars:

For detailed settings, use Palettes ChartElementSchemes:

Use a monochrome theme:

Labeling and Legending  (7)

Use Labeled to add a label to a dataset:

Use symbolic positions for label placement:

Provide value labels for bars by using LabelingFunction:

Use Placed to control placement and formatting:

Add categorical legend entries for datasets:

Use Legended to add additional legend entries:

Use Placed to affect the positioning of legends:

Options  (80)

AspectRatio  (3)

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

Make the height the same as the width with AspectRatio1:

AspectRatioFull adjusts the height and width to tightly fit inside other constructs:

Axes  (4)

By default, Axes are drawn:

Use AxesFalse to turn off axes:

Use AxesOrigin to specify where the axes intersect:

Turn each axis on individually:

AxesLabel  (4)

No axes labels are drawn by default:

Place a label on the axis:

Specify axes labels:

Use units as labels:

AxesOrigin  (2)

The position of the axes is determined automatically:

Specify an explicit origin for the axes:

AxesStyle  (4)

Change the style for the axes:

Specify the style of each axis:

Use different styles for the ticks and the axes:

Use different styles for the labels and the axes:

BarOrigin  (1)

Change the bar origin:

ChartBaseStyle  (4)

Use ChartBaseStyle to style bars:

ChartBaseStyle combines with ChartStyle:

ChartStyle may override settings for ChartBaseStyle:

ChartBaseStyle combines with Style:

Style may override settings for ChartBaseStyle:

ChartBaseStyle combines with ColorFunction:

ColorFunction may override settings for ChartBaseStyle:

ChartElementFunction  (4)

Get a list of built-in settings for ChartElementFunction:

For detailed settings, use Palettes ChartElementSchemes:

ChartElementFunction is appropriate to show the global scale:

Write a custom ChartElementFunction:

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

ChartElements  (9)

Create a pictorial chart based on any Graphics object:

Graphics3D:

Image:

Use a stretched version of the graphic:

Use explicit sizes for width and height:

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

Use a different graphic for each row of data:

Graphics are used cyclically:

Styles are inherited from styles set through ChartStyle etc:

Style can override the settings from ChartStyle:

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

Create true 3D-shaded bars:

ChartLabels  (6)

Place dataset labels above each histogram:

Labeled wrappers around datasets will place additional labels:

Use Placed to control label placement:

Symbolic positions outside the bar:

Coordinate-based placement relative to a histogram:

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

Use the third argument to Placed to control formatting:

Use a named formatting function:

Use a hyperlink label:

Place multiple labels:

ChartLayout  (5)

Use different layouts to display multiple datasets:

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

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

Use a row instead of a column:

Use multiple columns or rows:

Prefer full columns or rows:

ChartLegends  (2)

Generate a legend based on chart style:

Use Legended to add additional legend entries:

Use Legended to specify individual legend entries:

Use Placed to control the placement of legends:

ChartStyle  (5)

Use ChartStyle to style bars:

Give a list of styles:

Use "Gradient" colors from ColorData:

Use "Indexed" colors from ColorData:

Styles are used cyclically:

Style overrides settings for ChartStyle:

ColorFunction overrides settings for ChartStyle:

ChartElements may override settings for ChartStyle:

ColorFunction  (4)

Color by bar height:

Use ColorFunctionScaling->False to get unscaled height values:

ColorFunction overrides styles in ChartStyle:

Use ColorFunction to combine different style effects:

ColorFunctionScaling  (2)

By default, scaled height values are used:

Use ColorFunctionScaling->False to get unscaled height values:

ImageSize  (7)

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

Specify the width of the plot:

Specify the height of the plot:

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

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

Setting AspectRatioFull will fill the available space:

Use maximum sizes for the width and height:

Use ImageSizeFull to fill the available space in an object:

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

LabelingFunction  (7)

Use automatic labeling by values through Tooltip and StatusArea:

Do no labeling:

Use symbolic positions to control label placement:

Coordinate-based placement relative to a bar:

Control the formatting of labels:

Use the dataset position index to generate the label:

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

PerformanceGoal  (1)

Generate a bar chart with interactive highlighting:

Emphasize performance by disabling interactive behaviors:

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

PlotRange  (1)

PlotRange is automatically calculated:

Show all bins:

PlotRangePadding  (3)

Specify a single plot range padding for all directions:

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

Specify a separate plot range padding for each direction:

PlotTheme  (2)

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

Change the color scheme:

Applications  (14)

Overlay a plot of the PDF for a normal distribution:

Number of elements discovered each decade from 1700 to 2000:

Create a histogram of reference page sizes in the Wolfram System:

Distribution of lengths of human chromosomes:

Create a ListLinePlot using counts extracted from a histogram:

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

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

Create a matrix of handwritten digits using Graphics Drawing Tools:

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

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

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

Select a subset of languages available in DictionaryLookup:

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

Power spectrum of the ThueMorse nested sequence [more info]:

Distribution of frequencies:

Create a cumulative histogram:

Create a stacked cumulative histogram:

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

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

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

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

Create a polar histogram of the wind-direction frequencies:

Histogram for the slice distribution of a random process:

Histogram for several slices of a process:

Properties & Relations  (3)

Histogram automatically determines bins to use based on data:

Use BinCounts for explicit binning of data:

Display using BarChart:

Use PDF to get a parametric probability density function:

Show together with Histogram of random data:

Possible Issues  (2)

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

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

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

Neat Examples  (1)

Overlay several PDF plots for Poisson distributions:

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

Text

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

CMS

Wolfram Language. 2008. "Histogram." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. 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_2024_histogram, author="Wolfram Research", title="{Histogram}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/Histogram.html}", note=[Accessed: 09-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_histogram, organization={Wolfram Research}, title={Histogram}, year={2021}, url={https://reference.wolfram.com/language/ref/Histogram.html}, note=[Accessed: 09-November-2024 ]}