# Histogram height

**URL:** <https://discourse.julialang.org/t/histogram-height/111699>\
**Category:** New to Julia\
**Tags:** plotting, statistics, histogram\
**Created:** [March 16, 2024, 3:15pm UTC](https://discourse.julialang.org/t/histogram-height/111699 "2024-03-16T15:15:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LoneWolf1304](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lonewolf1304/32/207791_2.png) [@LoneWolf1304](https://discourse.julialang.org/u/LoneWolf1304)\
**Post date:** [March 16, 2024, 3:15pm UTC](https://discourse.julialang.org/t/histogram-height/111699/1 "2024-03-16T15:15:25Z")

</div>

In python matplotlib, the hist() returns an array containing the bin heights of the histogram. How can I do this in julia? as far as i know, the corresponding histogram() function doesn’t return anything. What is the quickest way to get the bin heights of a normalised histogram?

---

<div class="post-metadata">

**Author:** ![sefffal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sefffal/32/23640_2.png) [@sefffal](https://discourse.julialang.org/u/sefffal)\
**Post date:** [March 16, 2024, 4:08pm UTC](https://discourse.julialang.org/t/histogram-height/111699/2 "2024-03-16T16:08:09Z")

</div>

Hi there!

I would recommend the StatsBase.jl package:

[https://juliastats.org/StatsBase.jl/stable/empirical/](https://juliastats.org/StatsBase.jl/stable/empirical/)

```julia
julia> using StatsBase, LinearAlgebra

julia> bins = [0,1,7]; # a small and a large bin

julia> obs = [0.5, 1.5, 1.5, 2.5]; # one observation in the small bin and three in the large

julia> h = fit(Histogram, obs, bins)
Histogram{Int64,1,Tuple{Array{Int64,1}}}
edges:
  [0, 1, 7]
weights: [1, 3]
closed: left
isdensity: false

julia> # observe isdensity = false and the weights field records the number of observations in each bin

julia> normalize(h, mode=:density)

```

`normalize` returns a new, normalized histogram objectz
