mjskay / ggdist

Visualizations of distributions and uncertainty

Home Page:https://mjskay.github.io/ggdist/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reverse scales on stat_pointinterval not working (working on other geoms)

jonnations opened this issue · comments

Maybe a bug or maybe a feature, but I can't reverse the axes when using stat_pointinterval. Reversing the axes works on other geoms though. I am using the dev version of tidybayes. Here's an example:

library(distributional)
library(tidybayes)
library(dplyr)

# Sample from docs
set.seed(1234)
df = data.frame(
  group = c("a", "b", "c"),
  value = rnorm(1500, mean = c(5, 7, 9), sd = c(1, 1.5, 1))
)
df %>%
  ggplot(aes(x = value, y = group)) +
  stat_pointinterval()

image

Reversed

df %>%
  ggplot(aes(x = value, y = group)) +
  stat_pointinterval() + scale_x_reversed()

#Warning message:
#Computation failed in `stat_pointinterval()`
#Caused by error in `-x`:
#! invalid argument to unary operator 

image

However, this works with stat_halfeye which (it seems?) contains a point interval

df %>%
  ggplot(aes(x = value, y = group)) +
  stat_halfeye() + scale_x_reverse()

image

I can't find a scale_x_reversed(), only a scale_x_reverse() (which should work...)

Agg, sorry about the typo. There actually was an issue (I swear), but reinstalling both ggdist and tidybayes in a new session seems to have fixed it. Thanks.

no worries, glad it's working now!