Created
November 8, 2016 18:52
-
-
Save arvi1000/0f958cf342c5ff054bddf5b43380453a to your computer and use it in GitHub Desktop.
sometimes you just want to visualize a quantity; this shows a given number of dots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sometimes you just want to visualize a quantity; this shows a given number of dots | |
library(ggplot2) | |
library(magrittr) | |
dot_count <- 300 | |
size <- ceiling(dot_count^.5) | |
data.frame(x = rep(1:size, each=size), | |
y = rep(size:1, size), | |
clr = sample(letters[1:6], size^2, replace=T), | |
id = 1:(size^2)) %>% | |
subset(id <= dot_count) %>% | |
ggplot(aes(x,y, color=clr)) + | |
#geom_point(size=4, show.legend = F) + # neat version | |
geom_jitter(size=4, show.legend = F, alpha=0.8) + # jitter version | |
scale_color_brewer(type='qual', palette='Set1') + | |
theme_void() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment