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

add examples for facet_title_horizontal() and similar functions #233

Open
chelseadickens opened this issue May 16, 2024 · 0 comments
Open

Comments

@chelseadickens
Copy link

chelseadickens commented May 16, 2024

Is it possible to add examples and more details about what facet_title_horizontal(), facet_title_left_horizontal(), and facet_title_right_horizontal() are supposed to do?

Thanks!

library(ggdist)
library(tidyverse)

df <- tibble(
  h = c(0,1,1,0, 0,2,2,0, 0,4/3,4/3,0, 0,1,1,0, 0,1.25,1.25,0, 0,.5,.5,0),
  x = c(0,1,4,5, 4,5,6,7, 6,7,9,10, 11,12,15,16, 1,2,4.2,5.2, 4,5,12,13),
  y = rep(c("a", "b", "a", "a", "b", "a"), each = 4),
  group = rep(c("c", "c", "d", "d", "c", "c"), each = 4),
  panel = rep(c("e", "e", "e", "e", "f", "f"), each = 4),
  name  = rep(c(1,    2, "3a","3b",  4,   5),  each = 4)
)

df_group = df %>%
  summarise(x = mean(x), .by = c(name, group, panel, y))


p2 <- function(){
  theme_set(facet_title_horizontal())
  fig = df %>%
    ggplot(aes(x = x, y = y, fill = group, thickness = h)) +
    geom_slab(color = "gray25", alpha = 0.75) +
    scale_y_discrete(expand = expansion(add = 0.1)) +
    scale_fill_brewer(palette = "Set2") +
    facet_grid(cols = vars(panel), labeller = "label_both") +
    labs("geom_slab() with default thickness scaling") 
  return(fig)
}

p2()

image

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