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

mcmc_areas_ridges don't overlay when using scale_y_discrete #287

Open
SamPassmore opened this issue Aug 2, 2022 · 0 comments
Open

mcmc_areas_ridges don't overlay when using scale_y_discrete #287

SamPassmore opened this issue Aug 2, 2022 · 0 comments

Comments

@SamPassmore
Copy link

Hi,

First - thanks to all developers for creating such a useful plotting package.

I have come across a bug in mcmc_areas_ridges recently, which means that the density plots created in mcmc_areas_ridges don't overlay properly when used in conjunction with scale_y_discrete.
I think this worked in the past, since I was reusing code from an earlier project which didn't have this problem - although I can't be sure.

Here is what the plot looks like without using scale_y_discrete
image

And here is the same plot, using scale_y_discrete to reorder the categories in the y axis
image

here is a working example:

library(bayesplot)

n = 100

posterior = 
  data.frame(x = rnorm(n),
             y = rnorm(n),
             z = rnorm(n),
             a = rnorm(n))

# Overlay works properly
mcmc_areas_ridges(posterior, prob = 0.89,
                  pars = c("x", "y", "z"))

# Use scale_y_discrete to reorder y axis means overlapping fails
mcmc_areas_ridges(posterior, prob = 0.89,
                  pars = c("x", "y", "z")) + 
  scale_y_discrete(labels = c("z", "y", "x"))

# Don't reorder, but still use scale_y_discrete - overlapping fails
mcmc_areas_ridges(posterior, prob = 0.89,
                  pars = c("x", "y", "z")) + 
  scale_y_discrete(labels = c("x", "y", "z"))

# final test that should do nothing
mcmc_areas_ridges(posterior, prob = 0.89) + 
  scale_y_discrete(labels = c("z", "y", "x", "a"))
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

No branches or pull requests

1 participant