Problem with line thickness in pp_check plot

Hi,

I’m trying to run pp_check for my Bayesian model. However, I can’t change the thickness of y and yrep lines. In the past, I could change it using the below code:

ppc1 <- pp_check(fit1, ndraws = 100)
p1 <- plot(ppc1) 
plot1 <- p1 + ggtitle("F1") + theme_classic() + theme(legend.text = element_text(size = 20), legend.title = element_text(size = 20), legend.position = c(1, -1.8), axis.text = element_text(size = 12), plot.title = element_text(hjust = 0.5, size = 16)) + guides(color = guide_legend(nrow = 1, title = NULL)) + scale_x_continuous(breaks = seq(-4, 4, 2), labels = c("", -2, 0, 2, "")) + scale_y_continuous(breaks = seq(0, 0.6, 0.3), labels = function(x) ifelse(x == 0, "0", scales::number_format(accuracy = 0.1)(x)), limits = c(0, 0.6)) + update_geom_defaults(geom = "line", aes(size = 2.0))

Any ideas on how to increase the width of the lines? (I also tried linewidth instead of size but didn’t work as well).

Do you want to change the size of the thicker line (representing the data) or of the thinner lines (representing the predictive distribution)? If you want to change the width of thinner lines I think you can just pass a size argument directly to pp_check(). Changing the width of the single thicker line might not be possible at the moment because that seems to be hardcoded in the source code to bayesplot::ppc_dens_overlay, which is the function pp_check() calls by default. I’m not sure why we hardcoded that and I’d be open to changing it.

1 Like

You can change the width of the thicker line by editing the linewidth parameter of the underlying ggplot2 object, e.g.:

p1 <- ppc1
p1$layers[[2]]$aes_params$linewidth <- .4
1 Like