Experiment
library(ggfoundry)
shape_names <- c("skeleton", "ghost", "spiderweb", "grimreaper", "gravestone")
shape_labels <- c(
"Skeleton",
"Ghost",
"Spider's web",
"Grim reaper",
"Gravestone"
)
ink <- "#36312F"
paper <- "#FAF7F0"
gallery <- tribble(
~x , ~shape , ~label , ~appearance , ~fill ,
1 , "skeleton" , "Skeleton" , "Filled" , "#DED2B6" ,
2 , "ghost" , "Ghost" , "Filled" , "#D5DDD3" ,
3 , "spiderweb" , "Spider's web" , "Filled" , "#AFBEB6" ,
4 , "grimreaper" , "Grim reaper" , "Filled" , "#A596B5" ,
5 , "gravestone" , "Gravestone" , "Filled" , "#AEA99C" ,
1 , "skeleton" , "Skeleton" , "Outline only" , NA ,
2 , "ghost" , "Ghost" , "Outline only" , NA ,
3 , "spiderweb" , "Spider's web" , "Outline only" , NA ,
4 , "grimreaper" , "Grim reaper" , "Outline only" , NA ,
5 , "gravestone" , "Gravestone" , "Outline only" , NA
)
events <- tribble(
~activity , ~shape , ~bookings ,
"Skeleton dance" , "skeleton" , 28 ,
"Ghost stories" , "ghost" , 42 ,
"Web workshop" , "spiderweb" , 16 ,
"Reaper walk" , "grimreaper" , 24 ,
"Graveyard tour" , "gravestone" , 12
) |>
arrange(bookings) |>
mutate(activity = fct_inorder(activity))
events <- tribble(
~activity , ~shape , ~bookings ,
"Skeleton dance" , "skeleton" , 28 ,
"Ghost stories" , "ghost" , 42 ,
"Web workshop" , "spiderweb" , 16 ,
"Reaper walk" , "grimreaper" , 24 ,
"Graveyard tour" , "gravestone" , 12
) |>
arrange(bookings) |>
mutate(activity = fct_inorder(activity))
my_theme <- function(){theme_minimal(base_size = 13) +
theme(
text = element_text(colour = ink),
axis.text = element_text(colour = ink),
panel.grid.major.y = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major.x = element_line(colour = "#E5DDD1"),
plot.background = element_rect(fill = paper, colour = NA),
panel.background = element_rect(fill = paper, colour = NA),
plot.title.position = "plot",
plot.margin = margin(12, 18, 12, 12)
)
}
{ggplot(events) +
aes(x = bookings, xend = 0) +
aes(y = activity, yend = activity) +
geom_segment(colour = "#DAD1C4", linewidth = 0.8) +
geom_casting(colour = ink, size = 0.17) +
aes(shape = shape |> I()) +
aes(fill = bookings) +
scale_fill_gradient(low = "#B5C1B2", high = "#D49A65") +
guides(fill = "none") +
geom_text(aes(label = bookings),
nudge_x = 4.5, hjust = 0, colour = ink, size = 4
) +
scale_x_continuous(
limits = c(0, 52),
breaks = seq(0, 50, 10),
expand = expansion(mult = 0)
) +
scale_y_discrete(expand = expansion(add = 0.65)) +
labs(title = "An imaginary Halloween evening", x = "Bookings", y = NULL) +
my_theme()} |>
codehover::ch_hover()
| ggplot(events) + |
| aes(x = bookings, xend = 0) + |
| aes(y = activity, yend = activity) + |
| geom_segment(colour = "#DAD1C4", linewidth = 0.8) + |
| geom_casting(colour = ink, size = 0.17) + |
| aes(shape = I(shape)) + |
| aes(fill = bookings) + |
| scale_fill_gradient(low = "#B5C1B2", high = "#D49A65") + |
| guides(fill = "none") + |
geom_text(aes(label = bookings), nudge_x = 4.5, hjust = 0, colour = ink, size = 4) + |
scale_x_continuous(limits = c(0, 52), breaks = seq(0, 50, 10), expand = expansion(mult = 0)) + |
| scale_y_discrete(expand = expansion(add = 0.65)) + |
labs(title = "An imaginary Halloween evening", x = "Bookings", y = NULL) + |
| my_theme() |