Skip to content

Instantly share code, notes, and snippets.

@trinker
Created April 16, 2017 17:37
Show Gist options
  • Select an option

  • Save trinker/b2e65b839cd51019f7db2c3442549191 to your computer and use it in GitHub Desktop.

Select an option

Save trinker/b2e65b839cd51019f7db2c3442549191 to your computer and use it in GitHub Desktop.
3d-like density plots
library(dplyr)
library(tidyr)
library(ggplot2)
library(gridExtra)
df = as.data.frame(setNames(lapply(jitter(sample(-2:2, 8, T)), function(x) rnorm(100, x)), c(LETTERS[1:8]))) %>%
gather("var", "value", A:H)
ggplot(df, aes(x=value)) +
geom_density(fill="black", col="white", lwd=1) +
facet_grid(var~., switch="y") +
theme(strip.text.x=element_blank(), panel.background=element_blank(),
panel.spacing.y=unit(-1, "cm"), panel.grid=element_blank(),
axis.ticks.y=element_blank(), axis.text.y=element_blank())
@trinker

trinker commented Apr 16, 2017

Copy link
Copy Markdown
Author

image

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