Skip to content

Instantly share code, notes, and snippets.

@andrewheiss
Last active April 21, 2020 06:18
Show Gist options
  • Save andrewheiss/fa0063e8282c02cf0f31e8443d8784be to your computer and use it in GitHub Desktop.
Save andrewheiss/fa0063e8282c02cf0f31e8443d8784be to your computer and use it in GitHub Desktop.
library(tidyverse)
library(patchwork)

diff_nu <- ggplot(data = tibble(x = c(0, 200)), aes(x = x)) +
  geom_area(stat = "function", fun = dexp, args = list(rate = 1/29), 
            fill = "darkblue", color = "black") +
  labs(x = expression(Normality ~ parameter ~ (nu)), y = "Density") +
  annotate(geom = "label", x = 100, y = 0.009, label = "Exponential(1/29)") +
  theme_minimal() +
  theme(panel.grid = element_blank(),
        axis.text.x = element_blank())
diff_mu <- ggplot(data = tibble(x = c(0, 100)), aes(x = x)) +
  geom_area(stat = "function", fun = dnorm, args = list(mean = 50, sd = 10),
            fill = "darkred", color = "black") +
  scale_x_continuous(breaks = c(seq(0, 100, 25)),
                     labels = c("−$50", "−$25", "Group average", "+$25", "+$50")) +
  annotate(geom = "label", x = 50, y = 0.01, label = "N(bar(x), 10)", parse = TRUE) +
  labs(x = expression(Average ~ donated ~ (mu)), y = NULL) +
  theme_minimal() +
  theme(panel.grid = element_blank(),
        axis.text.x = element_blank())
diff_sigma <- ggplot(data = tibble(x = c(0, 10)), aes(x = x)) +
  geom_area(stat = "function", fun = dcauchy, args = list(location = 0, scale = 1),
            fill = "darkorange", color = "black") +
  scale_x_continuous(labels = scales::dollar) +
  annotate(geom = "label", x = 5, y = 0.08, label = "Cauchy(0, 1)") +
  labs(x = expression(SD ~ donated ~ (sigma)), y = NULL) +
  theme_minimal() +
  theme(panel.grid = element_blank(),
        axis.text.x = element_blank())
diff_nu + diff_mu + diff_sigma

Created on 2019-02-25 by the reprex package (v0.2.1)

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