# How to weight a normalized histogram in Plots

**URL:** https://discourse.julialang.org/t/how-to-weight-a-normalized-histogram-in-plots/45111
**Category:** General Usage
**Tags:** question
**Created:** [August 17, 2020, 2:17pm UTC](https://discourse.julialang.org/t/how-to-weight-a-normalized-histogram-in-plots/45111 "2020-08-17T14:17:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [August 17, 2020, 2:17pm UTC](https://discourse.julialang.org/t/how-to-weight-a-normalized-histogram-in-plots/45111/1 "2020-08-17T14:17:56Z")

</div>

I would like to plot a joint distribution as two normalized histograms. One distribution has a weight w and the other has a weight 1-w. Unfortunately, I cannot figure out how to apply the weight to a normalized histogram.

```julia
using Plots, Distributions
y = rand(Normal(0, 1), 10_000)
w = .5
histogram(y, norm=true, weights=fill(w, 10_000))

```

The density does not change with the weights. Any help would be greatly appreciated

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [August 17, 2020, 3:17pm UTC](https://discourse.julialang.org/t/how-to-weight-a-normalized-histogram-in-plots/45111/2 "2020-08-17T15:17:56Z")

</div>

I think the problem is that it is normed after the weights are applied. Does anyone know of a work around?

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [August 17, 2020, 4:12pm UTC](https://discourse.julialang.org/t/how-to-weight-a-normalized-histogram-in-plots/45111/3 "2020-08-17T16:12:36Z")

</div>

Fortunately, the data can be accessed from the plot object and modified. It was just difficult to find.

```julia
using Plots, Distributions

y = rand(Normal(0, 1), 10_000)

w = .5

p = histogram(y, norm=true)

p[1][1][:y] .*= w

display(p)

```
