ASKurz / Doing-Bayesian-Data-Analysis-in-brms-and-the-tidyverse

The bookdown version lives here: https://bookdown.org/content/3686
GNU General Public License v3.0
147 stars 43 forks source link

plot_bar_den() #43

Closed ASKurz closed 2 years ago

ASKurz commented 2 years ago

Look at the final results of plot_bar_den () in section 23.1. The lower x-axis labels are partially cut off for the top three subplots. You'll need to find a way to adjust the spacing.

ASKurz commented 2 years ago

For the y_second_x argument within the plot_bar_den() function, it looks like you can make this adjustment based on the bar data:

bar %>% 
  group_by(panel) %>% 
  filter(percent == max(percent)) %>% 
  mutate(y_second_x = (percent + (percent_max / 15)) / -5)
  panel strip                 y     n percent percent_label percent_max y_second_x
  <int> <ord>             <dbl> <int>   <dbl> <chr>               <dbl>      <dbl>
1     1 mu==4~~sigma==1.5     4 26256      26 26%                    26      -5.55
2     2 mu==1~~sigma==2.5     1 58002      58 58%                    58     -12.4 
3     3 mu==4~~sigma==1       4 23512      24 24%                    24      -5.12
4     4 mu==4~~sigma==3       4 26098      26 26%                    26      -5.55

Just change the y_second_x values manually, keep the code in the .Rmd file but hidden with echo = FALSE, eval = FALSE, and make sure the scaling is good after a dry run building the ebook. Also, consider making similar adjustments to the first panel displayed earlier in the section before having defined the plot_bar_den() function.