lionel-/ggstance

facetting with free axes

lionel- opened this issue · 1 comments

From @smouksassi

require(gghorizon)
require(ggplot2)

set <- factor(rep(1:3, each=50), labels=c("DRUG A","DRUG B","Vehicle"))
subject <- factor(rep(1:6, each=25),
                 labels=c("A","B","C","D","E","F"))
result <- rnorm(150)
test <- data.frame(set, subject, result)

p <- ggplot(test, aes(subject, result))+
  geom_boxplot()+
  facet_grid(. ~ set)
p

p1 <- ggplot(test, aes(subject, result))+
  geom_boxplot()+
  facet_grid(. ~ set, space="free",
                             scales="free_x")

p1 # works but  how to we flip this plot ?

p1 +coord_flip() # wrong output incorrect y axis labels

#trying the new geom geom_boxploth

p2 <- ggplot(test, aes( result,subject))+
  geom_boxploth()+
  facet_grid(set ~.)

p2 # ptoduce the plot but let us try freeing the y axis


p3 <- ggplot(test, aes( result,subject))+
  geom_boxploth()+
  facet_grid(set ~.,scales="free_y")

p3
#Error in panel$y_scales[[this_panel$SCALE_Y]] : subscript out of bounds

Now fixed, let me now if you find anything else fishy :)