Using scale_x_continuous to change the scale of the x axis of a mcmc_areas() plot

This question is sort of tangential to this other question on the forum, but I’m trying to change the scale of my x-axis on an mcmc_areas() plot.

I have fit a lognormal() model, so I would like to show the mcmc_areas() on the exponentiated scale, rather than the log scale. I think I need to do this with something like

mcmc_areas(model) + scale_x_continuous(trans = exp_trans)

But when I do this, nothing happens (no plot is rendered, with no error message either). It would also be neat if I could generalize the transformation, so if I wanted to use the scale from preprocessing to get the % change for every one unit of change in the variable, I could.

Any help would be greatly appreciated. Also, as an aside, thanks to the folks who contributed to bayesplot, I’m finding the library really helpful.

So I read the docs more thoroughly and I think I’m going to be able to answer my own question, will post here in case others stumble upon this and it helps them.

mcmc_areas(
  model,
transformations = function(x) exp(x)
)

…will do the trick. Can also specify transformations = “exp” if all you want to do is apply exp(), but using the throwaway function also makes it easy to generalize so you can perform any custom transformation you want.

2 Likes