Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't replicate vignette plots for mcmc_rhat and mcmc_neff #327

Closed
adcascone opened this issue Jul 30, 2024 · 2 comments · Fixed by #328
Closed

can't replicate vignette plots for mcmc_rhat and mcmc_neff #327

adcascone opened this issue Jul 30, 2024 · 2 comments · Fixed by #328

Comments

@adcascone
Copy link

adcascone commented Jul 30, 2024

Hello,

I'm trying to recreate the plots in the "Visual MCMC diagnostics using the bayesplot package" - specifically those under the 'mcmc_rhat, mcmc_rhat_hist' section and the 'mcmc_neff' section.

When I run this code in the vignette to reproduce the mcmc_rhat() output:

color_scheme_set("brightblue") # see help("color_scheme_set")
mcmc_rhat(rhats)

The resulting plot is missing the line/point in the legend for the first two bins:
image

I see the same behavior in the subsequent plot, when y-axis text is added to the plot.

And when I run this code in the vignette to reproduce the mcmc_neff() output:

mcmc_neff(ratios_cp, size = 2)

The resulting plot is again missing a line/point in the legend:

image

Is this behavior expected? I noticed there are no data points in the bins that are missing from the legend so the plot's interpretations are not technically impacted. That said, it seems odd to have an incomplete legend.

-- Here are the relevant details of my R session --

> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] bayesplot_1.11.1   shiny_1.8.1.1

--

Thanks for the guidance!
Arianna C.

@jgabry
Copy link
Member

jgabry commented Jul 30, 2024

Thanks for reporting this. That's definitely not intentional! It's strange because I'm pretty sure this wasn't an issue in the past, so I wonder if something changed in ggplot2 at some point that's causing this. Maybe we just need to change how we're creating the legend to play nicely with a change in ggplot2.

@jgabry
Copy link
Member

jgabry commented Jul 30, 2024

Ok I think this should be fixed by #328. I'll include this in the next release, but for now you can install the fixed version from that GitHub branch using

remotes::install_github("stan-dev/bayesplot", ref = "fix-diagnostic-legends")

If you're able to try it out let me know if that fixes the issue for you. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants