bayesplot icon indicating copy to clipboard operation
bayesplot copied to clipboard

Feature request (or help): Use different colors for posterior draws for some parameters in mcmc_area()

Open freshbeka opened this issue 4 years ago • 3 comments

I'd like to the color of a few specific variables in my mcmc_area() plot to be one color, while the rest are another color. Referencing your plot from the Posterior uncertainty intervals vignette, say I wanted only the pars = "cyl" posterior distribution in blue, and the rest ("drat", "am", "sigma"), still in red. Is this already possible and I'm failing to figure it out? Thank you for your beautiful and helpful package!

freshbeka avatar Nov 12 '21 03:11 freshbeka

Unfortunately I think the way the package is designed makes this quite difficult. If you're willing to do some more manual ggplot2 coding (as opposed to using the single functions provided by bayesplot), you could probably accomplish something similar to what you want using @mjskay's ggdist package. In general bayesplot is useful for providing simple function calls to get immediate feedback after fitting models (and provides some but not extensive customization ability), whereas a package like ggdist requires more coding but is much more powerful when it comes to the ability to customize the plots.

jgabry avatar Nov 12 '21 17:11 jgabry

Thank you for this guidance. For a workaround, I mimicked one of the vignette examples and added the 'rhat' call. I assigned fake r-hat values to each of my predictor variables of 1, 1.1, 1.3 according to category (I have 3 categories) and the call + legend_move("none"). It works well enough for now and I'll give ggdist a look so that I can make a cleaner plot with a legend when the time comes. Thank you!

freshbeka avatar Nov 12 '21 18:11 freshbeka

For a workaround, I mimicked one of the vignette examples and added the 'rhat' call.

Great idea! That didn't even occur to me.

jgabry avatar Nov 12 '21 18:11 jgabry