Skip to content

Instantly share code, notes, and snippets.

@chichacha
Created December 29, 2018 20:47
Show Gist options
  • Save chichacha/f8199f3a47a97a0f641e6d03d4ac6918 to your computer and use it in GitHub Desktop.
Save chichacha/f8199f3a47a97a0f641e6d03d4ac6918 to your computer and use it in GitHub Desktop.
Simple Beeswarm Plot as Experiment
install.packages("beeswarm")
library(beeswarm)
library(tidyverse)
library(scales)
df <- tibble(
x = sample(x=c(2,6,17,24,25), size=3000, replace=T),
#x = sample(x=c(1,10,13,16,19,20,21), size=3000, replace=T),
y = rbeta(3000,2,5),
hex = as.character(cut_number(y,n=10,labels=viridis_pal()(10))),
fill = ifelse(rbinom(3000,1,prob=0.2),"#000000","#ffffff20")
)
cairo_pdf(filename="Test2.pdf", width=16, height=9, bg="#000000de",
pointsize=12)
par(ann=FALSE, mar=c(0,0,0,0), bg="black")
beeswarm(y~x, data=df, method="swarm",
pwcol = df$hex, pch=sort(unique(df$x)),
pwbg=df$fill)
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment