Skip to content

Instantly share code, notes, and snippets.

View bmjstau's full-sized avatar

Ben Stauch bmjstau

View GitHub Profile
# somewhat hackish solution to:
# https://twitter.com/EamonCaddigan/status/646759751242620928
# based mostly on copy/pasting from ggplot2 geom_violin source:
# https://github.com/hadley/ggplot2/blob/master/R/geom-violin.r
library(ggplot2)
library(dplyr)
"%||%" <- function(a, b) {
## GOAL:
## re-create a figure similar to Fig. 2 in Wilson et al. (2018),
## Nature 554: 183-188. Available from:
## https://www.nature.com/articles/nature25479#s1
##
## combines a boxplot (or violin) with the raw data, by splitting each
## category location in two (box on left, raw data on right)
# initial set-up ----------------------------------------------------------
@bmjstau
bmjstau / gammatron.frag
Last active April 6, 2018 10:40
Mockup of an OpenGL Gammatron shader. Post this into http://editor.thebookofshaders.com/ to get a quick visual impression.
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time; // this should be replaced by frame number in use
const float tau = 2.0*3.141592654;
const float direction = 1.0; // must be -1 or 1
const float tempPeriod = 0.7;
const float spacePeriod = 0.1;
@bmjstau
bmjstau / wesAnderson.m
Last active April 18, 2019 10:41
Wes Anderson Colormaps
function [rgb] = wesAnderson(N, which)
% wesAnderson returns N colors taken from Wes Anderson's films, which
% can be used as color maps for hipster line plots. Colors have been
% adapted from https://github.com/karthik/wesanderson, who has them from
% http://wesandersonpalettes.tumblr.com/.
%
% Inputs:
% INT N Number of colors. Is limited by color palette.
% CHAR which Name of color palette. See
% https://github.com/karthik/wesanderson for previews.