# Plotting priors in traceplot

**URL:** <https://discourse.pymc.io/t/plotting-priors-in-traceplot/860>\
**Category:** Questions\
**Created:** [February 15, 2018, 1:55pm UTC](https://discourse.pymc.io/t/plotting-priors-in-traceplot/860 "2018-02-15T13:55:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aplavin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/aplavin/32/259_2.png) [@aplavin](https://discourse.pymc.io/u/aplavin)\
**Post date:** [February 15, 2018, 1:55pm UTC](https://discourse.pymc.io/t/plotting-priors-in-traceplot/860/1 "2018-02-15T13:55:03Z")

</div>

There is a `priors` argument in `traceplot`, but it isn’t intuitive to use at all. Currently I call the function as `pm.traceplot(trace, varnames, priors=[getattr(model[n], 'distribution', None) for n in varnames], combined=True)`, and it provides expected results for my cases (visually). But as I couldn’t find anything like this neither in documentation nor in discussion, I’m not sure if that’s always correct and will not give some nonsense results sometime? Or maybe there is a more straightforward method for this, as plotting priors taken from a model looks like the most common usecase for `priors` argument?

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [February 15, 2018, 4:46pm UTC](https://discourse.pymc.io/t/plotting-priors-in-traceplot/860/2 "2018-02-15T16:46:04Z")

</div>

Yeah I dont think many ppl is using it, as it gets quite confusing with multi-chain and/or multivariate RVs. It is great for demonstration purpose in low dimension toy problems, a use case is something like this:

```auto
with pm.Model() as m:
    mu = pm.Normal('mu', 0, 1)
    sd = pm.HalfCauchy('sd', 1.5)
    obs = pm.Normal('obs', mu, sd, observed=np.random.randn(10)*2.5+1)
    trace = pm.sample()

pm.traceplot(trace, 
             combined=True,
             priors=[pm.Normal.dist(0., 1), pm.HalfCauchy.dist(2.5)]);

# this is also allow
pm.traceplot(trace, 
             combined=True,
             priors=[mu.distribution, sd.distribution]);

```

So yes I think what you are doing is correct at least in univariate cases.

---

<div class="post-metadata">

**Author:** ![aplavin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/aplavin/32/259_2.png) [@aplavin](https://discourse.pymc.io/u/aplavin)\
**Post date:** [February 15, 2018, 8:27pm UTC](https://discourse.pymc.io/t/plotting-priors-in-traceplot/860/3 "2018-02-15T20:27:47Z")

</div>

Ok, thanks for confirmation 🙂  
And I personally often use such prior-plots when I suspect that the prior may have a strong influence. Multi-chain doesn’t look like a problem, as `combined=True` is needed even without prior-plots when there are multivariate RVs: otherwise the plots are way to messy.
