Skip to content

Instantly share code, notes, and snippets.

@gdbassett
Created February 12, 2021 15:54
Show Gist options
  • Save gdbassett/707120b9a9deadc4a41942450e972c5b to your computer and use it in GitHub Desktop.
Save gdbassett/707120b9a9deadc4a41942450e972c5b to your computer and use it in GitHub Desktop.
library(tidyverse)
options(repr.plot.width=16, repr.plot.height=16)
tibble(axis_1 = c(0, 0, 1, 1), axis_2 = c(0, 1, 0, 1),
count = c(72164, 303490, 129222, 594717)) %>%
mutate(scale = 581) %>%
mutate(scaled_count = count/scale) %>%
mutate(data = purrr::map(scaled_count, ~ tibble(x=rep(1:32, 32), y=rep(1:32, each=32)) %>% head(round(.x)))) %>%
unnest(data) %>%
mutate(x = if_else(axis_1 == 1, x, -x)) %>%
mutate(y = if_else(axis_2 == 1, y, -y)) %>%
mutate(quadrant = paste0(axis_1, "-", axis_2)) %>%
#glimpse() %>%
ggplot() +
geom_hline(aes(yintercept = 0)) +
geom_vline(aes(xintercept = 0)) +
geom_point(aes(x=x, y=y, fill=quadrant), shape=22, size=7) +
scale_x_continuous(expand=c(0,0), limits=c(-32.5, 32.5), breaks=seq(0,32,8)) +
scale_y_continuous(expand=c(0,0), limits=c(-32.5, 32.5), breaks=seq(0,32,8)) +
theme(
axis.text = element_blank(),
axis.ticks = element_blank(),
panel.background = element_blank(),
panel.grid.minor = element_blank()
) +
NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment