SmoothHistogram[{x1,x2,…}]
plots a smooth kernel histogram for the PDF of the values xi.
SmoothHistogram[{x1,x2,…},espec]
plots a smooth kernel histogram with estimator specification espec.
SmoothHistogram[{x1,x2,…},espec,dfun]
plots the distribution function dfun.
SmoothHistogram[{data1,data2,…},…]
plots smooth kernel histograms for multiple datasets datai.
SmoothHistogram
SmoothHistogram[{x1,x2,…}]
plots a smooth kernel histogram for the PDF of the values xi.
SmoothHistogram[{x1,x2,…},espec]
plots a smooth kernel histogram with estimator specification espec.
SmoothHistogram[{x1,x2,…},espec,dfun]
plots the distribution function dfun.
SmoothHistogram[{data1,data2,…},…]
plots smooth kernel histograms for multiple datasets datai.
Details and Options
- SmoothHistogram is also known as nonparametric kernel density estimator or kernel estimator.
- SmoothHistogram plots
for a smoothing kernel
as an estimate of the PDF. - Data for SmoothHistogram can be given in the following forms:
-
{e1,e2,…} list of elements with or without wrappers <|k1y1,k2y2,…|> association of keys and lengths TimeSeries[…],EventSeries[…],TemporalData[…] time series, event series, and temporal data WeightedData[…],EventData[…] augmented datasets w[{e1,e2,…},…] wrapper applied to a whole dataset w[{data1,data1,…},…] wrapper applied to all datasets - SmoothHistogram[objcspec] extracts and plots values from the Tabular, TimeSeries, or EventSeries object obj using the key specification cspec.
- The following specifications cspec are allowed for plotting tabular data:
-
{cx,cy,cz} histogram values from key z against values from keys x and y {{cx1,cy1,cz1},{cx2,cy2,cz2},…} histogram key z1 against keys x1 and y1 , z2 against x2 and y2, etc. - The estimator specification espec can be of the form bw or {bw,kernel}.
- The specifications for bandwidth bw and kernel are the same as for SmoothKernelDistribution.
- Possible distribution functions dfun include:
-
"PDF" probability density function "Intensity" count density function "CDF" cumulative distribution function "SF" survival function "HF" hazard function "CHF" cumulative hazard function - The form w[data] provides a wrapper w to be applied to the resulting graphics primitives.
- The following wrappers can be used:
-
Annotation[e,label] provide an annotation Button[e,action] define an action to execute when the element is clicked EventHandler[e,…] define a general event handler for the element Highlighted[e,effect] dynamically highlight e with an effect Highlighted[e,Placed[effect,pos]] statically highlight e with an effect at position pos Hyperlink[e,uri] make the element act as a hyperlink 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 - SmoothHistogram has the same options as Graphics with the following additions and changes: [List of all options]
-
AspectRatio 1/GoldenRatio ratio of width to height Axes True whether to draw axes ClippingStyle None what to draw where curves are clipped ColorFunction Automatic how to determine the coloring of curves ColorFunctionScaling True whether to scale arguments to ColorFunction Filling None filling to insert under each curve FillingStyle Automatic style to use for filling MaxRecursion Automatic the maximum number of recursive subdivisions allowed Mesh None how many mesh points to draw on each curve MeshFunctions {#1&} how to determine the placement of mesh points MeshShading None how to shade regions between mesh points MeshStyle Automatic the style for mesh points Method Automatic methods to use PerformanceGoal $PerformanceGoal aspects of performance to try to optimize PlotHighlighting Automatic highlighting effect for curves PlotPoints Automatic initial number of sample points PlotRange Automatic range of values to include PlotRangeClipping True whether to clip at the plot range PlotStyle Automatic graphics directives to specify the style for each object PlotTheme $PlotTheme overall theme for the plot RegionFunction (True&) how to determine whether a point should be included ScalingFunctions None how to scale individual coordinates WorkingPrecision MachinePrecision the precision used in internal computations for symbolic distributions - Typical settings for PlotLegends include:
-
None no legend Automatic automatically determine legend {lbl1,lbl2,…} use lbl1, lbl2, … as legend labels Placed[lspec,…] specify placement for legend - PlotStylesty 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["DefaultPlotColors"] gives the default sequence of colors used by PlotStyle.
- Possible settings for PlotLayout that show single curves in multiple plot panels include:
-
"Column" use separate curves in a column of panels "Row" use separate curves 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 - The arguments supplied to RegionFunction, MeshFunctions, and ColorFunction are x and f, where f can be the PDF, CDF, etc. of the distribution.
- Possible highlighting effects for Highlighted and PlotHighlighting include:
-

style highlight the indicated curve 
"Ball" highlight and label the indicated point in a curve 
"Dropline" highlight and label the indicated point in a curve with droplines to the axes 
"XSlice" highlight and label all points along a vertical slice 
"YSlice" highlight and labels all points along a horizontal slice 
Placed[effect,pos] statically highlight the given position pos - Highlight position specifications pos include:
-
x,{x} effect at {x,y} with y chosen automatically {x,y} effect at {x,y} {pos1,pos2,…} multiple positions posi - With ScalingFunctions->{sx,sy}, the
coordinate is scaled using sx and the
coordinate is scaled using sy. -
AlignmentPoint Center the default point in the graphic to align with AspectRatio 1/GoldenRatio ratio of width to height Axes True whether to draw axes AxesLabel None axes labels AxesOrigin Automatic where axes should cross AxesStyle {} style specifications for the axes Background None background color for the plot BaselinePosition Automatic how to align with a surrounding text baseline BaseStyle {} base style specifications for the graphic ClippingStyle None what to draw where curves are clipped ColorFunction Automatic how to determine the coloring of curves ColorFunctionScaling True whether to scale arguments to ColorFunction ContentSelectable Automatic whether to allow contents to be selected CoordinatesToolOptions Automatic detailed behavior of the coordinates tool Epilog {} primitives rendered after the main plot Filling None filling to insert under each curve FillingStyle Automatic style to use for filling FormatType TraditionalForm the default format type for text Frame False whether to put a frame around the plot FrameLabel None frame labels FrameStyle {} style specifications for the frame FrameTicks Automatic frame ticks FrameTicksStyle {} style specifications for frame ticks GridLines None grid lines to draw GridLinesStyle {} style specifications for grid lines ImageMargins 0. the margins to leave around the graphic ImagePadding All what extra padding to allow for labels etc. ImageSize Automatic the absolute size at which to render the graphic LabelStyle {} style specifications for labels MaxRecursion Automatic the maximum number of recursive subdivisions allowed Mesh None how many mesh points to draw on each curve MeshFunctions {#1&} how to determine the placement of mesh points MeshShading None how to shade regions between mesh points MeshStyle Automatic the style for mesh points Method Automatic methods to use PerformanceGoal $PerformanceGoal aspects of performance to try to optimize PlotHighlighting Automatic highlighting effect for curves PlotLabel None an overall label for the plot PlotPoints Automatic initial number of sample points PlotRange Automatic range of values to include PlotRangeClipping True whether to clip at the plot range PlotRangePadding Automatic how much to pad the range of values PlotRegion Automatic the final display region to be filled PlotStyle Automatic graphics directives to specify the style for each object PlotTheme $PlotTheme overall theme for the plot PreserveImageOptions Automatic whether to preserve image options when displaying new versions of the same graphic Prolog {} primitives rendered before the main plot RegionFunction (True&) how to determine whether a point should be included RotateLabel True whether to rotate y labels on the frame ScalingFunctions None how to scale individual coordinates Ticks Automatic axes ticks TicksStyle {} style specifications for axes ticks WorkingPrecision MachinePrecision the precision used in internal computations for symbolic distributions
List of all options
Examples
open all close allBasic Examples (3)
SmoothHistogram[RandomVariate[ExponentialDistribution[1 / 2], 500]]SmoothHistogram[Table[RandomVariate[NormalDistribution[c, 1], 500], {c, 0, 5}]]Plot the probability density function of the data:
data = RandomVariate[NormalDistribution[0, 1], 500];SmoothHistogram[data, Automatic, "PDF"]Cumulative distribution function:
SmoothHistogram[data, Automatic, "CDF"]SmoothHistogram[data, Automatic, "SF"]SmoothHistogram[data, Automatic, "HF"]SmoothHistogram[data, Automatic, "CHF"]Scope (32)
Data (11)
SmoothHistogram[Table[RandomVariate[NormalDistribution[i, 1 / i], 10 ^ 4], {i, 4}], Filling -> Axis]Plot different distribution functions:
Table[SmoothHistogram[RandomVariate[NormalDistribution[], 1000], Automatic, dfun, Filling -> Axis, PlotLabel -> dfun], {dfun, {"PDF", "CDF", "SF", "HF", "CHF"}}]PlotRange is selected automatically:
data = RandomVariate[WeibullDistribution[2, 1], 10 ^ 3];SmoothHistogram[data]Use PlotRange to focus on areas of interest:
SmoothHistogram[data, PlotRange -> {{1.25, 3}, {0, 0.5}}]Non-real data points are ignored:
data = {2.0, 1.9, 1.0, 1.1, 0.4, 1.3, 1.2, 0. + 0.5 I, 1., 0. + 0.9 I};{SmoothHistogram[data], SmoothHistogram[Cases[data, _Real]]}Specify the number of times to refine the curve:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], MaxRecursion -> 0]data = RandomVariate[NormalDistribution[2, 1], 10 ^ 3];SmoothHistogram[Style[data, Dashed, Thick]]Override the default tooltips:
data = RandomVariate[NormalDistribution[2, 1], 10 ^ 3];SmoothHistogram[Tooltip[data, "normal distribution"]]Use any object in the tooltip:
SmoothHistogram[Tooltip[data, BoxWhiskerChart[data]]]Use PopupWindow to provide additional drilldown information:
data = RandomVariate[NormalDistribution[2, 1], 10 ^ 3];SmoothHistogram[PopupWindow[data, Histogram[data]]]Numeric values in an association are used as the y coordinates:
SmoothHistogram[<|"a" -> 2, "b" -> 3, "c" -> 5, "d" -> 7, "e" -> 11, "f" -> 13|>]Numeric keys and values in an association are used as the x and y coordinates:
SmoothHistogram[<|2 -> 1, 3 -> 2, 5 -> 3, 7 -> 4, 11 -> 5, 13 -> 6|>]data = CountryData["UnitedStates", {{"Population"}, {1988, 2013}}]SmoothHistogram[data, AxesLabel -> Automatic]The weights in WeightedData are ignored:
SmoothHistogram[WeightedData[{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}]]Tabular Data (3)
tabular = Tabular[ExampleData[{"Statistics", "USCars1993"}], ExampleData[{"Statistics", "USCars1993"}, "ColumnHeadings"]]Create a smooth histogram for the city mileage:
SmoothHistogram[tabular -> "MPGcity"]Compare the distributions of city and highway mileages:
SmoothHistogram[tabular -> {"MPGcity", "MPGhighway"}]Vary the bandwidth to affect the smoothness of the histograms:
{SmoothHistogram[tabular -> {"MPGcity", "MPGhighway"}, 0.5], SmoothHistogram[tabular -> {"MPGcity", "MPGhighway"}, 5]}Histogram the values for all the components in TimeSeries or EventSeries:
SmoothHistogram[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:
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[]];SmoothHistogram[temps -> "Champaign"]Histogram values from multiple components:
SmoothHistogram[temps -> {"Oxford", "Tokyo"}, PlotLegends -> {"Oxford", "Tokyo"}]Bandwidth and Kernel (9)
Automatically select the bandwidth to use:
data1 = RandomVariate[d = NormalDistribution[], 10];
data2 = RandomVariate[d, 10 ^ 4];More data yields better approximations to the underlying distribution:
Table[Show[SmoothHistogram[data, Automatic, "PDF", Filling -> Axis], Plot[PDF[d, x], {x, -4, 4}]], {data, {data1, data2}}]Explicitly specify the bandwidth:
data = RandomVariate[NormalDistribution[], 10 ^ 3];Larger bandwidths yield smoother estimates:
Table[SmoothHistogram[data, bw, Filling -> Axis], {bw, {.05, 1.}}]Specify bandwidths in units of standard deviation:
data = RandomVariate[NormalDistribution[], 10 ^ 3];Use bandwidths of
and
of the standard deviation:
Table[SmoothHistogram[data, {"Standardized", bw}, Filling -> Axis], {bw, {1 / 2, 1 / 8}}]Allow bandwidth to vary adaptively with local density:
data = RandomVariate[NormalDistribution[], 10 ^ 3];Vary the local sensitivity from
(none) to
(full):
Table[SmoothHistogram[data, {"Adaptive", Automatic, s}, Filling -> Axis, PlotLabel -> s], {s, {0, .25, .75, 1}}]Vary the initial bandwidth for an adaptive estimate:
data = RandomVariate[NormalDistribution[], 10 ^ 3];Specify an initial bandwidth of
and
respectively:
𝒟1 = SmoothKernelDistribution[data, {"Adaptive", 1.0, .5}];
𝒟2 = SmoothKernelDistribution[data, {"Adaptive", 0.1, .5}];Table[Plot[PDF[𝒟, x], {x, -4, 4}, Filling -> Axis, Exclusions -> None], {𝒟, {𝒟1, 𝒟2}}]Use any of several automatic bandwidth selection methods:
data = RandomVariate[NormalDistribution[], 10 ^ 2];Table[SmoothHistogram[data, name, Filling -> Axis, PlotLabel -> name], {name, {"LeastSquaresCrossValidation", "Oversmooth", "Scott", "SheatherJones", "StandardDeviation", "StandardGaussian"}}]Silverman's method is used by default for bandwidth selection:
data = RandomVariate[NormalDistribution[], 10 ^ 3];Table[SmoothHistogram[data, bw, Filling -> Axis], {bw, {"Silverman", Automatic}}]Specify any one of several kernel functions:
data = RandomVariate[NormalDistribution[], 100];Table[SmoothHistogram[data, {Automatic, i}, Filling -> Axis, PlotLabel -> i, Ticks -> None], {i, {"Biweight", "Cosine", "Epanechnikov", "Gaussian", "Rectangular", "SemiCircle", "Triangular", "Triweight"}}]Define the kernel function as a pure function:
data = RandomVariate[NormalDistribution[], 100];Table[SmoothHistogram[data, {Automatic, ker}, Filling -> Axis], {ker, {"Gaussian", (1/π (1 + #1^2))&}}]Presentation (9)
Multiple datasets are automatically colored to be distinct:
data = Table[RandomVariate[NormalDistribution[c, 1], 500], {c, 4}];SmoothHistogram[data]Provide explicit styling to different sets:
data = Table[RandomVariate[NormalDistribution[c, 1], 500], {c, 4}];SmoothHistogram[data, PlotStyle -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.98, 0.56, 0.17], RGBColor[0.4, 0.6, 1], RGBColor[0.8, 0.3, 0.8]}]Use rows and columns of individual plots to show multiple sets:
SmoothHistogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»]}, PlotLayout -> "Row"]SmoothHistogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»]}, PlotLayout -> "Column"]SmoothHistogram[RandomVariate[WeibullDistribution[2, 1], 10 ^ 4], AxesLabel -> {"x", "pdf"}, PlotLabel -> "Weibull Distribution", PlotStyle -> Directive[Thick, RGBColor[0.8, 0.3, 0.8]], Filling -> Axis]Use the default tooltip for the data:
data1 = RandomVariate[NormalDistribution[2, 1], 500];
data2 = RandomVariate[WeibullDistribution[2, 1], 500];SmoothHistogram[{Tooltip[data1], Tooltip[data2]}]Provide an interactive tooltip for the data:
data1 = RandomVariate[NormalDistribution[2, 1], 500];
data2 = RandomVariate[WeibullDistribution[2, 1], 500];SmoothHistogram[{Tooltip[data1, BoxWhiskerChart[data1]], Tooltip[data2, BoxWhiskerChart[data2]]}]data1 = RandomVariate[NormalDistribution[2, 1], 500];
data2 = RandomVariate[WeibullDistribution[2, 1], 500];SmoothHistogram[{data1, data2}, Filling -> {1 -> {{2}, {RGBColor[0.93, 0.27, 0.27], RGBColor[0.4, 0.6, 1]}}}]SmoothHistogram[RandomVariate[NormalDistribution[0, 1], 100], Mesh -> 10, Frame -> True, Axes -> False]Style the curve segments between mesh points:
SmoothHistogram[RandomVariate[NormalDistribution[0, 1], 100], Mesh -> 10, MeshShading -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.4, 0.6, 1]}, Frame -> True, Axes -> False]Options (86)
AspectRatio (4)
By default, SmoothHistogram uses a fixed height to width ratio for the plot:
SmoothHistogram[IconizedObject[«random data»]]Make the height the same as the width with AspectRatio1:
SmoothHistogram[IconizedObject[«random data»], AspectRatio -> 1]AspectRatioAutomatic determines the ratio from the plot ranges:
SmoothHistogram[IconizedObject[«random data»], AspectRatio -> Automatic]AspectRatioFull adjusts the height and width to tightly fit inside other constructs:
plot = SmoothHistogram[IconizedObject[«random data»], AspectRatio -> Full];{Framed[Pane[plot, {50, 100}]], Framed[Pane[plot, {100, 100}]], Framed[Pane[plot, {100, 50}]]}Axes (4)
SmoothHistogram[IconizedObject[«random data»]]Use AxesFalse to turn off axes:
SmoothHistogram[IconizedObject[«random data»], Axes -> False]Use AxesOrigin to specify where the axes intersect:
SmoothHistogram[IconizedObject[«random data»], AxesOrigin -> {-4, 0}]Turn each axis on individually:
{SmoothHistogram[IconizedObject[«random data»], Axes -> {True, False}], SmoothHistogram[IconizedObject[«random data»], Axes -> {False, True}]}AxesLabel (4)
No axes labels are drawn by default:
SmoothHistogram[IconizedObject[«data»]]SmoothHistogram[IconizedObject[«data»], AxesLabel -> y]SmoothHistogram[IconizedObject[«data»], AxesLabel -> {x, y}]SmoothHistogram[QuantityArray[IconizedObject[«data»], "Meters"], AxesLabel -> Automatic]AxesOrigin (2)
AxesStyle (4)
Change the style for the axes:
SmoothHistogram[IconizedObject[«random data»], AxesStyle -> RGBColor[0.93, 0.27, 0.27]]Specify the style of each axis:
SmoothHistogram[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:
SmoothHistogram[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:
SmoothHistogram[IconizedObject[«random data»], AxesStyle -> RGBColor[0.14, 0.8, 0.14], LabelStyle -> RGBColor[0.93, 0.27, 0.27]]ClippingStyle (4)
Omit clipped regions of the plot:
SmoothHistogram[Range[0, 1, 0.01], Automatic, "HF"]Show the clipped regions like the rest of the curve:
SmoothHistogram[Range[0, 1, 0.01], Automatic, "HF", ClippingStyle -> Automatic, PlotStyle -> Thick]Show the clipped regions with red lines:
SmoothHistogram[Range[0, 1, 0.01], Automatic, "HF", ClippingStyle -> RGBColor[0.93, 0.27, 0.27]]Show the clipped regions as red and thick:
SmoothHistogram[Range[0, 1, 0.01], Automatic, "HF", ClippingStyle -> Directive[RGBColor[0.93, 0.27, 0.27], Thick]]ColorFunction (5)
Color by scaled
and
coordinates:
Table[SmoothHistogram[RandomVariate[NormalDistribution[], 100], ColorFunction -> Function[{x, y}, f], PlotLabel -> f, PlotStyle -> Thick], {f, {Hue[x], Hue[y]}}]Color with a named color scheme:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], ColorFunction -> "DarkRainbow"]Fill with the color used for the curve:
SmoothHistogram[RandomVariate[NormalDistribution[1, 2], 100], ColorFunction -> Function[{x, y}, Hue[x]], Filling -> Axis]ColorFunction has higher priority than PlotStyle for coloring the curve:
SmoothHistogram[RandomVariate[NormalDistribution[1, 2], 100], ColorFunction -> "DarkRainbow", PlotStyle -> Directive[RGBColor[0.93, 0.27, 0.27], Thick]]Use Automatic in MeshShading to use ColorFunction:
SmoothHistogram[RandomVariate[NormalDistribution[1, 2], 100], ColorFunction -> "Rainbow", PlotStyle -> Directive[RGBColor[0.93, 0.27, 0.27], Thick], Mesh -> 9, MeshShading -> {Automatic, GrayLevel[0.62]}, MeshStyle -> None]ColorFunctionScaling (2)
Color the line based on scaled
value:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], ColorFunction -> Function[{x, y}, Hue[y]], PlotStyle -> Thick, ColorFunctionScaling -> True]Color the line based on unscaled
value:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], ColorFunction -> Function[{x, y}, Hue[y]], PlotStyle -> Thick, ColorFunctionScaling -> False]Filling (6)
Use symbolic or explicit values:
Table[SmoothHistogram[Range[-2, 2, 0.05], Filling -> c, PlotLabel -> c], {c, {Top, Bottom, Axis, 0.1}}]By default, overlapping fills combine using opacity:
SmoothHistogram[{RandomVariate[NormalDistribution[], 14], RandomVariate[PoissonDistribution[1], 10]}, Filling -> Axis]Fill between curve 1 and the
axis:
SmoothHistogram[{RandomVariate[NormalDistribution[], 14], RandomVariate[PoissonDistribution[1], 10]}, Filling -> {1 -> Axis}]SmoothHistogram[{RandomVariate[NormalDistribution[], 14], RandomVariate[PoissonDistribution[1], 10]}, Filling -> {1 -> {2}}]Fill between datasets using a particular style:
SmoothHistogram[{RandomVariate[NormalDistribution[], 14], RandomVariate[PoissonDistribution[1], 10]}, Filling -> {1 -> {{2}, Directive[RGBColor[0.98, 0.56, 0.17], Opacity[.6]]}}]Use different styles above and below the filling level:
SmoothHistogram[{RandomVariate[NormalDistribution[], 14], RandomVariate[PoissonDistribution[1], 10]}, Filling -> {1 -> {{2}, {RGBColor[1, 0.75, 0], RGBColor[0.93, 0.27, 0.27]}}}]FillingStyle (4)
Table[SmoothHistogram[RandomReal[NormalDistribution[1, 10], 100], Filling -> Bottom, FillingStyle -> c], {c, {RGBColor[0.93, 0.27, 0.27], RGBColor[0.14, 0.8, 0.14], RGBColor[0.4, 0.6, 1], RGBColor[1, 0.75, 0]}}]SmoothHistogram[Table[RandomVariate[NormalDistribution[x, 2x], 100], {x, 1, 2}], Filling -> Bottom, FillingStyle -> Directive[Opacity[0.5], RGBColor[0.98, 0.56, 0.17]]]Fill with red when the first curve is below the second, and blue when the second is below the first:
SmoothHistogram[Table[RandomVariate[NormalDistribution[x, 2x], 100], {x, 1, 2}], Filling -> {1 -> {2}}, FillingStyle -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.4, 0.6, 1]}]Use a variable filling style obtained from a ColorFunction:
SmoothHistogram[RandomReal[NormalDistribution[1, 10], 100], ColorFunction -> Function[{x, y}, Hue[y]], Filling -> Axis, FillingStyle -> Automatic]ImageSize (7)
Use named sizes such as Tiny, Small, Medium and Large:
{SmoothHistogram[IconizedObject[«random data»], ImageSize -> Tiny], SmoothHistogram[IconizedObject[«random data»], ImageSize -> Small]}Specify the width of the plot:
{SmoothHistogram[IconizedObject[«random data»], ImageSize -> 150], SmoothHistogram[IconizedObject[«random data»], AspectRatio -> 1.5, ImageSize -> 150]}Specify the height of the plot:
{SmoothHistogram[IconizedObject[«random data»], ImageSize -> {Automatic, 150}], SmoothHistogram[IconizedObject[«random data»], AspectRatio -> 2, ImageSize -> {Automatic, 150}]}Allow the width and height to be up to a certain size:
{SmoothHistogram[IconizedObject[«random data»], ImageSize -> UpTo[200]], SmoothHistogram[IconizedObject[«random data»], AspectRatio -> 2, ImageSize -> UpTo[200]]}Specify the width and height for a graphic, padding with space if necessary:
SmoothHistogram[IconizedObject[«random data»], ImageSize -> {200, 200}, Background -> RGBColor[1, 0.75, 0]]Setting AspectRatioFull will fill the available space:
SmoothHistogram[IconizedObject[«random data»], AspectRatio -> Full, ImageSize -> {200, 200}, Background -> RGBColor[1, 0.75, 0]]Use maximum sizes for the width and height:
{SmoothHistogram[IconizedObject[«random data»], ImageSize -> {UpTo[150], UpTo[100]}], SmoothHistogram[IconizedObject[«random data»], AspectRatio -> 2, ImageSize -> {UpTo[150], UpTo[100]}]}Use ImageSizeFull to fill the available space in an object:
Framed[Pane[SmoothHistogram[IconizedObject[«random data»], AspectRatio -> Full, ImageSize -> Full, Background -> RGBColor[1, 0.75, 0]], {200, 200}]]Specify the image size as a fraction of the available space:
Framed[Pane[SmoothHistogram[IconizedObject[«random data»], AspectRatio -> Full, ImageSize -> {Scaled[0.5], Scaled[0.5]}, Background -> RGBColor[1, 0.75, 0]], {200, 200}]]MaxRecursion (2)
SmoothHistogram[RandomVariate[NormalDistribution[1, 10], 100], Mesh -> All]Each level of MaxRecursion will subdivide the initial mesh into a finer mesh:
Table[SmoothHistogram[RandomVariate[NormalDistribution[1, 10], 100], MaxRecursion -> i, Mesh -> All, Ticks -> None], {i, {0, 3, 6}}]Mesh (3)
Use 20 mesh levels evenly spaced in the
direction:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], Mesh -> 20]Use an explicit list of values for the mesh in the
direction:
data = RandomVariate[UniformDistribution[{1, 10}], 100];SmoothHistogram[data, Mesh -> {Range[0, 12, 2]}, MeshStyle -> PointSize[Medium]]Specify and mesh levels and styles in the
direction:
data = RandomVariate[UniformDistribution[{1, 10}], 100];SmoothHistogram[data, Mesh -> {Table[{x, Hue[x / (2)]}, {x, 0., 12, .5}]}]MeshFunctions (2)
Use a mesh evenly spaced in the
and
directions:
Table[SmoothHistogram[RandomVariate[NormalDistribution[1, 10], 100], MeshFunctions -> {Function[{x, y}, Evaluate[f]]}, Mesh -> 9, PlotLabel -> f], {f, {x, y}}]Show five mesh levels in the
direction (red) and 10 in the
direction (blue):
SmoothHistogram[RandomVariate[NormalDistribution[1, 10], 100], Mesh -> {5, 10}, MeshFunctions -> {#1&, #2&}, MeshStyle -> {Directive[PointSize[Medium], RGBColor[0.93, 0.27, 0.27]], RGBColor[0.4, 0.6, 1]}]MeshShading (6)
Alternate red and blue segments of equal width in the
direction:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], Mesh -> 10, MeshShading -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.4, 0.6, 1]}]Use None to remove segments:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], Mesh -> 10, MeshShading -> {RGBColor[0.93, 0.27, 0.27], None}]MeshShading can be used with PlotStyle:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], Mesh -> 10, PlotStyle -> Thick, MeshFunctions -> {#1&}, MeshShading -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.4, 0.6, 1]}]MeshShading has higher priority than PlotStyle for styling the curve:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], Mesh -> 10, PlotStyle -> Green, MeshFunctions -> {#1&}, MeshShading -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.4, 0.6, 1]}]Use PlotStyle for some segments by setting MeshShading to Automatic:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], Mesh -> 10, PlotStyle -> Directive[Thick, RGBColor[1, 0.75, 0]], MeshFunctions -> {#1&}, MeshShading -> {RGBColor[0.93, 0.27, 0.27], Automatic}]MeshShading can be used with ColorFunction:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], Mesh -> 10, PlotStyle -> Thick, MeshFunctions -> {#1&}, MeshShading -> {GrayLevel[0.62], Automatic},
ColorFunction -> Function[{x, y}, Hue[x]]]MeshStyle (4)
Color the mesh the same color as the plot:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], Mesh -> 9, MeshStyle -> Automatic]Use a red mesh in the
direction:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], Mesh -> 9, MeshStyle -> Red]Use a red mesh in the
direction and a blue mesh in the
direction:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], Mesh -> 9, MeshStyle -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.4, 0.6, 1]}, MeshFunctions -> {#1&, #2&}]Use big, red mesh points in the
direction:
SmoothHistogram[RandomVariate[NormalDistribution[], 100], Mesh -> 10, MeshStyle -> Directive[PointSize[Large], RGBColor[0.93, 0.27, 0.27]]]PerformanceGoal (2)
Generate a higher-quality plot:
Timing[SmoothHistogram[RandomVariate[NormalDistribution[], 100], PerformanceGoal -> "Quality"]]Emphasize performance, possibly at the cost of quality:
Timing[SmoothHistogram[RandomVariate[NormalDistribution[], 100], PerformanceGoal -> "Speed"]]PlotLabels (3)
Place dataset labels above each histogram:
data1 = RandomVariate[NormalDistribution[0, 1], 500];
data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500];
data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];SmoothHistogram[{data1, data2, data3}, PlotLabels -> Placed[{"a", "b", "c"}, Above], PlotRange -> All]Coordinate-based placement relative to a histogram:
data = RandomVariate[NormalDistribution[0, 1], 500];Table[SmoothHistogram[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:
data = RandomVariate[NormalDistribution[0, 1], 500];Table[SmoothHistogram[data, PlotLabels -> Placed[{Framed["label"]}, {{0, 0}, p}], Ticks -> None, PlotLabel -> p], {p, {{0, 0}, {0.5, 0.5}, {1, 1}}}]PlotLayout (3)
Place each histogram in a separate panel using shared axes:
SmoothHistogram[{IconizedObject[«normal data»], IconizedObject[«Weibull data»]}, ImageSize -> Medium, PlotLayout -> "Column"]Use a row instead of a column:
SmoothHistogram[{IconizedObject[«normal data»], IconizedObject[«Weibull data»]}, ImageSize -> Medium, PlotLayout -> "Row"]SmoothHistogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»], IconizedObject[«σ = 3»], IconizedObject[«σ = 4»]}, ImageSize -> Medium, PlotLayout -> {"Column", 2}]SmoothHistogram[{IconizedObject[«σ = 1»], IconizedObject[«σ = 2»], IconizedObject[«σ = 3»], IconizedObject[«σ = 4»], IconizedObject[«σ = 5»], IconizedObject[«σ = 6»]}, ImageSize -> Medium, PlotLayout -> {"Column", UpTo[4]}]SmoothHistogram[{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:
data1 = RandomVariate[NormalDistribution[0, 1], 500];
data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500];
data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];SmoothHistogram[{data1, data2, data3}, PlotLegends -> {"John", "Mary", "Bob"}]Use Placed to control the placement of legends:
data1 = RandomVariate[NormalDistribution[0, 1], 500];
data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500];
data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];SmoothHistogram[{data1, data2, data3}, PlotLegends -> Placed[{"ccc1", "ccc2", "ccc3"}, Below]]Place the legend inside the plot:
SmoothHistogram[{data1, data2, data3}, PlotLegends -> Placed[{"ccc1", "ccc2", "ccc3"}, {Left, Top}]]Use SwatchLegend to control the legend appearance:
data1 = RandomVariate[NormalDistribution[0, 1], 500];
data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500];
data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];SmoothHistogram[{data1, data2, data3}, PlotLegends -> SwatchLegend[Automatic, {"ccc1", "ccc2", "ccc3"}, LegendFunction -> Framed]]PlotPoints (1)
PlotRange (2)
PlotRange is automatically calculated:
data = RandomVariate[WeibullDistribution[2, 4], 100];SmoothHistogram[data, Automatic, "HF"]SmoothHistogram[data, Automatic, "HF", PlotRange -> All]SmoothHistogram automatically chooses the plotting domain:
data = RandomVariate[ExponentialDistribution[1], 500];SmoothHistogram[data]Plot over the middle 90% of the data:
SmoothHistogram[data, PlotRange -> {Quantile[data, {0.05, 0.95}], All}]PlotStyle (7)
Use different style directives:
Table[SmoothHistogram[RandomVariate[ExponentialDistribution[1 / 2], 500], PlotStyle -> ps], {ps, {RGBColor[0.93, 0.27, 0.27], Thick, Dashed, Directive[RGBColor[0.93, 0.27, 0.27], Thick]}}]By default, different styles are chosen for multiple curves:
SmoothHistogram[Table[RandomVariate[ExponentialDistribution[x], 100], {x, 1, 4, 1}]]Explicitly specify the style for different curves:
SmoothHistogram[{RandomVariate[NormalDistribution[1, 1], 50], RandomVariate[NormalDistribution[2, 1], 50], RandomVariate[NormalDistribution[3, 1], 50]}, PlotStyle -> {RGBColor[0.98, 0.56, 0.17], RGBColor[0.8, 0.3, 0.8], RGBColor[0, 0.74, 0.74]}]Use the association-based syntax to set a base style for all data:
data1 = RandomVariate[NormalDistribution[0, 1], 500];
data2 = RandomVariate[NormalDistribution[3, 1 / 2], 500];
data3 = RandomVariate[NormalDistribution[5, 1 / 3], 500];SmoothHistogram[{data1, data2, data3}, PlotStyle -> <|"Base" -> AbsoluteThickness[5]|>]Use a different style for each of the datasets:
SmoothHistogram[{data1, data2, data3}, PlotStyle -> <|"Lists" -> {RGBColor[0.98, 0.56, 0.17], RGBColor[0.8, 0.3, 0.8], RGBColor[0, 0.74, 0.74]}|>]Provide an overall base style as well as styles for each dataset:
SmoothHistogram[{data1, data2, data3}, PlotStyle -> <|"Base" -> AbsoluteThickness[5], "Lists" -> {RGBColor[0.98, 0.56, 0.17], RGBColor[0.8, 0.3, 0.8], RGBColor[0, 0.74, 0.74]}|>]PlotStyle can be combined with ColorFunction:
SmoothHistogram[RandomVariate[ExponentialDistribution[1 / 2], 500], PlotStyle -> Thick, ColorFunction -> Function[{x, y}, Hue[y]]]PlotStyle can be combined with MeshShading:
SmoothHistogram[RandomVariate[ExponentialDistribution[1 / 2], 500], PlotStyle -> Directive[Opacity[0.5], Thick], Mesh -> 10, MeshFunctions -> {#1&}, MeshShading -> {RGBColor[0.93, 0.27, 0.27], RGBColor[0.4, 0.6, 1]}]MeshStyle by default uses the same style as PlotStyle:
SmoothHistogram[RandomVariate[ExponentialDistribution[1 / 2], 500], PlotStyle -> RGBColor[0.93, 0.27, 0.27], Mesh -> All]PlotTheme (2)
Use a theme with simple ticks and grid lines in a high contrast color scheme:
SmoothHistogram[{Table[Sin[x], {x, 0, 2Pi, 1}], Table[Cos[x], {x, 0, 2Pi, 0.1}]}, PlotTheme -> "Business"]SmoothHistogram[{Table[Sin[x], {x, 0, 2Pi, 1}], Table[Cos[x], {x, 0, 2Pi, 0.1}]}, PlotTheme -> "Business", PlotStyle -> {RGBColor[0.23780781740448254, 0.6887454706969063, 1.], RGBColor[1., 0.519599248047801, 0.3096774660909407]}]Applications (4)
The velocities in km/sec of 82 galaxies from six well-separated conic sections of an unfilled survey of the Corona Borealis region. Multimodality in such surveys is evidence for voids and superclusters in the far universe:
data = ExampleData[{"Statistics", "GalaxyVelocity"}];Multiple modes are readily detected for a variety of bandwidths:
bw = {"Oversmooth", "Silverman", "SheatherJones", "LeastSquaresCrossValidation"};Table[SmoothHistogram[data, i], {i, bw}]Observe the density over many possible bandwidths and choose one that captures important features of the data while smoothing out noise. For presentation, it is best to choose a bandwidth that slightly undersmooths the data:
snow = ExampleData[{"Statistics", "BuffaloSnow"}];Manipulate[SmoothHistogram[snow, h, PerformanceGoal -> "Quality", PlotRange -> {{0, 150}, {0, .03}}, Axes -> {True, False}, Filling -> Axis], {h, 1.5, 15}, SaveDefinitions -> True]Choosing 6.0 seems to capture the important features of the snowfall data:
SmoothHistogram[snow, 6.0, Filling -> Axis, PlotLabel -> "Buffalo Snowfall Records: h -> 6.0"]Visually compare data to a parametric model of its density:
data = RandomVariate[MixtureDistribution[{.5, .5}, {NormalDistribution[-1, 1], NormalDistribution[1, .5]}], 10^3];model = EstimatedDistribution[data, MixtureDistribution[{.5, .5}, {NormalDistribution[mu1, sigma1], NormalDistribution[mu2, sigma2]}]]Show[Plot[PDF[model, x], {x, -5, 5}, PlotStyle -> {Thick, RGBColor[0.4, 0.6, 1]}], SmoothHistogram[data, PlotStyle -> {Thick, RGBColor[0.93, 0.27, 0.27]}]]Smooth histogram for the slice distribution of a random process:
data = RandomVariate[WienerProcess[3, 4][7], 10 ^ 4];SmoothHistogram[data, 20, "PDF", Filling -> Axis]Smooth histogram for several slices of a process:
{data1, data2, data3} = Table[RandomVariate[WienerProcess[3, 4][t], 10 ^ 4], {t, {1, 3, 7}}];SmoothHistogram[{data1, data2, data3}, Filling -> Axis, PlotLegends -> {"t=1", "t=3", "t=7"}]Properties & Relations (5)
SmoothHistogram effectively plots the distribution function of SmoothKernelDistribution:
data = RandomVariate[NormalDistribution[], 20];{SmoothHistogram[data, PlotRange -> {{-3, 3}, All}], Plot[PDF[SmoothKernelDistribution[data], x], {x, -3, 3}]}Use Histogram to plot the data in discrete bins:
data = RandomVariate[NormalDistribution[], 1000];{Histogram[data, {0.25}, "PDF"], SmoothHistogram[data, PlotStyle -> Thick]}Show[%]Use SmoothDensityHistogram and SmoothHistogram3D for bivariate data:
data = RandomVariate[BinormalDistribution[{1 / 3, 1 / 2}, {1, 1 / 2}, 0], 100];{SmoothDensityHistogram[data], SmoothHistogram3D[data]}Additional points will result in a better approximation of the underlying distribution:
data = RandomVariate[NormalDistribution[], 10 ^ 5];Table[SmoothHistogram[RandomSample[data, i], PlotLabel -> i], {i, {10, 10 ^ 3, 10 ^ 5}}]As the bandwidth approaches infinity, the estimate approaches the shape of the kernel:
data = {-.5, 0, .5};𝒦 = {"Gaussian", "Epanechnikov", "Biweight", "Triweight", "Rectangular", "Triangular", "Cosine", "SemiCircle"};Table[SmoothHistogram[data, {200, k}, Ticks -> None, PlotLabel -> k], {k, 𝒦}]Possible Issues (1)
Using SmoothHistogram with multivariate data will plot multiple curves:
data = RandomVariate[BinormalDistribution[{1 / 3, 1 / 2}, {1, 1 / 2}, 0], 10]SmoothHistogram[data]Neat Examples (1)
A visual explanation of kernel density estimation:
data = {-3.5, -.5, 4.5, 5.5, 6.5};h = 1.0;kernels = NormalDistribution[#, h]& /@ data;kernelPlots = Show[Table[Plot[.15PDF[i, x], {x, -10, 15}, PlotRange -> All, PlotStyle -> {RGBColor[0.93, 0.27, 0.27], Dashed}], {i, kernels}]];dataRug = Show[Table[Graphics[{RGBColor[0.14, 0.8, 0.14], Line[{{i, 0}, {i, .15PDF[NormalDistribution[0, h], 0]}}]}], {i, data}]];The estimate results from mixing the kernel functions placed at each data point:
Show[SmoothHistogram[data, h, Frame -> True, Axes -> None, PlotStyle -> Thick, PlotRange -> {{-7, 11}, All}], kernelPlots, dataRug]Related Guides
-
▪
- Statistical Visualization ▪
- Tabular Visualization ▪
- Statistical Data Analysis ▪
- Charting and Information Visualization ▪
- Random Variables ▪
- Reliability ▪
- Time Series Processing ▪
- Nonparametric Statistical Distributions ▪
- Probability & Statistics with Quantities ▪
- Event Series Processing ▪
- Tabular Processing Overview
History
Introduced in 2010 (8.0) | Updated in 2014 (10.0) ▪ 2015 (10.2) ▪ 2021 (13.0) ▪ 2023 (13.3) ▪ 2025 (14.2) ▪ 2026 (15.0)
Text
Wolfram Research (2010), SmoothHistogram, Wolfram Language function, https://reference.wolfram.com/language/ref/SmoothHistogram.html (updated 2026).
CMS
Wolfram Language. 2010. "SmoothHistogram." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/SmoothHistogram.html.
APA
Wolfram Language. (2010). SmoothHistogram. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SmoothHistogram.html
BibTeX
@misc{reference.wolfram_2026_smoothhistogram, author="Wolfram Research", title="{SmoothHistogram}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/SmoothHistogram.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_smoothhistogram, organization={Wolfram Research}, title={SmoothHistogram}, year={2026}, url={https://reference.wolfram.com/language/ref/SmoothHistogram.html}, note=[Accessed: 12-June-2026]}