Skip to content

Instantly share code, notes, and snippets.

@gadenbuie
Last active March 17, 2020 16:26
Show Gist options
  • Save gadenbuie/de3e84ce35a300dec6ab36f5b23710bb to your computer and use it in GitHub Desktop.
Save gadenbuie/de3e84ce35a300dec6ab36f5b23710bb to your computer and use it in GitHub Desktop.
library(ggplot2)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

tested <- 2004

g <- 
  tibble(
    status = c("Tested", "Not Tested"),
    count = c(tested, 21477737 - tested)
  ) %>% 
  arrange(status) %>% 
  ggplot() +
  aes(x = 1, count, fill = status, color = status) +
  geom_col(position = "fill") +
  scale_fill_manual(
    values = c(Tested = "red", "Not Tested" = "#dddddd"),
    guide = FALSE
  ) +
  scale_color_manual(
    values = c(Tested = "red", "Not Tested" = "#dddddd"),
    guide = FALSE
  ) +
  scale_y_continuous(expand = expansion(add = c(0.05, 0))) +
  labs(
    caption = paste(
      "Florida DOH reports 2,004 tests have been conducted.",
      "There are 21,477,737 residents in Florida.",
      sep = "\n"
    )
  ) +
  annotate(
    "curve",
    x = 1.46, y = 0,
    xend = 1.55, yend = 0.05,
    curvature = -0.4,
    angle = 100,
    arrow = arrow(length = unit(5, "pt"), type = "closed", ends = "first")
  ) +
  annotate(
    "text",
    x = 1.55, y = 0.055,
    label = "Tested",
    hjust = 0,
    family = "Helvetica Neue"
  ) +
  annotate(
    "text",
    x = 1, y = 0.5,
    label = "Not Tested",
    hjust = 0.5,
    color = "#aaaaaa",
    size = 20,
    family = "Helvetica Neue"
  ) +
  coord_flip() +
  theme_void(base_family = "Gill Sans", base_size = 18) +
  ggtitle(
    "How many Floridians have been tested for COVID-19?"
  ) +
  theme(
    plot.title = element_text(hjust = 0.6, margin = margin(t = 1, b = 0.66, unit = "line")),
    plot.caption = element_text(color = "#666666", hjust = 1),
    plot.margin = margin(r = 2, b = 1, unit = "lines")
  )

g

Created on 2020-03-17 by the reprex package (v0.3.0)

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