Skip to content

Instantly share code, notes, and snippets.

@baptiste
Last active May 27, 2023 05:10
Show Gist options
  • Save baptiste/5420f696ae45fb535845305cebeea654 to your computer and use it in GitHub Desktop.
Save baptiste/5420f696ae45fb535845305cebeea654 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(readr)
library(ggfittext)
d <- read_csv('PrevalenceAtLarge.csv')
d$value <- cut(d$PercentAtLarge, breaks = 5,
labels = c("doubling under 6 weeks",
"doubling in 2–6 weeks",
"stable",
"halving in 2–6 weeks",
"halving under 6 weeks"))
d$label <- format(d$PercentAtLarge, digits=1)
d$DHB <- factor(d$DHB, levels = rev(unique(d$DHB)))
ggplot(d, aes(Age, DHB, fill = value, label = label)) +
geom_tile(col='grey',lwd=0.3) +
geom_fit_text(reflow = FALSE, grow = FALSE, contrast = TRUE, show.legend = FALSE) +
scale_fill_brewer("",palette = "PRGn") +
theme_bw() +
theme(panel.border = element_rect(fill = NA,
colour = 'grey90')) +
scale_x_discrete(expand=c(0,0))+
scale_y_discrete(expand=c(0,0)) +
guides(fill=guide_legend()) +
labs(x="",y="")
ggsave('covid_horiz.png',width=8, height=4)
@baptiste
Copy link
Author

covid_horiz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment