Skip to content

Instantly share code, notes, and snippets.

@martinmodrak
Created January 4, 2023 19:28
Show Gist options
  • Save martinmodrak/07b3a25e4cf555630b611d2b8f4af28c to your computer and use it in GitHub Desktop.
Save martinmodrak/07b3a25e4cf555630b611d2b8f4af28c to your computer and use it in GitHub Desktop.
Profile and header picture for https://bayes.club/@statmodeling_bot
#Profile
ggplot(data.frame(x = 1:3, y = c(5, 7, 1)), aes(x, y)) +
geom_bar(stat = "identity", fill = "#6364ff", color = FALSE) +
theme_void() +
theme(plot.margin = margin(15,15,15,15))
# Header
set.seed(55465)
x <- 0:100
m <- splines::bs(x = x, df = 5, intercept = TRUE) %*% matrix(rnorm(5 * 50), ncol = 50, nrow = 5)
a <- data.frame(x = x, y = rowMeans(m))
d <- tidyr::pivot_longer(data.frame(sample = 1:50, t(m)), cols = 2:(length(x) + 1), names_to = "x", values_to = "y", names_prefix = "X")
d$x <- as.numeric(d$x) - 1
ggplot(d, aes(x, y + ((x - 50)/40) ^ 3 + (x/200) ^ 2)) +
geom_line(data = a, size = 2) +
geom_line(aes(group = sample), alpha = 0.7, color = "#6364ff") +
coord_cartesian(expand = FALSE) +
theme_void()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment