# Plotting a StatsBase.Histogram

**URL:** https://discourse.julialang.org/t/plotting-a-statsbase-histogram/3293
**Category:** Visualization
**Created:** [April 20, 2017, 4:27am UTC](https://discourse.julialang.org/t/plotting-a-statsbase-histogram/3293 "2017-04-20T04:27:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jstrube](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jstrube/32/525_2.png) [@jstrube](https://discourse.julialang.org/u/jstrube)
#### Post date: [April 20, 2017, 4:27am UTC](https://discourse.julialang.org/t/plotting-a-statsbase-histogram/3293/1 "2017-04-20T04:27:26Z")

</div>

Another particle physicist who likes step histograms here.  
I’ve googled and came across this:  
[https://github.com/JuliaStats/StatsBase.jl/pull/243](https://github.com/JuliaStats/StatsBase.jl/pull/243)  
I very much like the plots shown here, but this doesn’t seem to work (and I think this is unrelated to the fact that this pull request isn’t in a released version). Plots.jl does weird things when trying to plot a StatsBase.Histogram.  
It also does weird things when doing things like `histogram(randn(1000), bins=100, seriestype=:steps)`

So my question is: What’s the recommended way to plot a StatsBase.Histogram?

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [April 20, 2017, 5:46am UTC](https://discourse.julialang.org/t/plotting-a-statsbase-histogram/3293/2 "2017-04-20T05:46:58Z")

</div>

There is a companion PR ([https://github.com/JuliaPlots/Plots.jl/pull/713](https://github.com/JuliaPlots/Plots.jl/pull/713)) on Plots that depends on this PR (EDIT in fact that PR was already merged onto the `new_histogram` branch). If you checkout the linked PR and the `new_histogram` branch in Plots it should work. It’d be cool if you could test it.  
Until this gets merged, there is functionality in StatPlots to plot StatsBase.Histogram, but you won’t have the `steps` seriestype.

---

<div class="post-metadata">

### Author: ![jstrube](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jstrube/32/525_2.png) [@jstrube](https://discourse.julialang.org/u/jstrube)
#### Post date: [April 21, 2017, 5:31am UTC](https://discourse.julialang.org/t/plotting-a-statsbase-histogram/3293/3 "2017-04-21T05:31:05Z")

</div>

Checked out the JuliaPlots branch, and applied the pull request to StatsBase.  
Non-uniform binning is no longer broken. (try, for example to histogram a normal distribution with the bins [-2.5, -2, -0.5, 0.1, 1.9, 2.5]. Using `histogram`, the bars overlap.  
With the new version I can just do

````nohighlight
plot(h)``` 
or 
`plot(h, seriestype=:steps)` and everything looks as expected.

That's as easy as it should be. Admittedly this is not a particularly thorough test, but I hope this gets merged soon.
````
