A Custom Logo

February 16 2017
R

I thought it would be fun to make a custom logo for the site. Below is the code I used to plot Anscombe’s quartet.

library(tidyr)
library(dplyr)
library(ggplot2)

data(anscombe)

wide <- cbind(
    data.frame(row = 1:nrow(anscombe)),
    anscombe
)

long <- wide %>%
    gather("variable", "value", -1) %>%
    mutate(
        dataset = as.integer(substr(variable, 2, 2)),
        variable = substr(variable, 1, 1)
    ) %>%
    spread("variable", "value")

g <- ggplot(long, aes(x = x, y = y)) +
    ## geom_line(stat = "smooth", method = "lm", se = FALSE, color = "white", size = 1, alpha = 0.5) +
    geom_point(color = "white", size = 0.25) +
    facet_wrap(~ dataset) +
    theme_bw() +
    xlab(NULL) +
    ylab(NULL) +
    theme(
        panel.background = element_rect(fill = gray(0.4), color = "black"),
        strip.background = element_blank(),
        strip.text.x = element_blank(),
        axis.ticks = element_blank(),
        axis.text = element_blank(),
        panel.spacing = unit(0.3, "lines"),
        plot.margin = unit(c(0, 0, 0, 0), "mm")
    ) +
    scale_x_continuous(breaks = NULL, limits = c(3.5, 19.5)) +
    scale_y_continuous(breaks = NULL, limits = c(2, 14)) +
    coord_fixed()

## install.packages("svglite")
ggsave("logo.svg", g, height = 1, width = 1.25, dpi = 50)
system("cp logo.svg ../../static/images/")
system("rm logo.svg")
comments powered by Disqus