Skip to content

Instantly share code, notes, and snippets.

@alcantarar
Last active March 26, 2020 17:14
Show Gist options
  • Save alcantarar/93ca573719c4c2eca6a63c1b58f083c2 to your computer and use it in GitHub Desktop.
Save alcantarar/93ca573719c4c2eca6a63c1b58f083c2 to your computer and use it in GitHub Desktop.
pre_race = c(-5,-4,-3,0,0,0,0,0,0,3,4,5)
post_race_0 = c(-5,2,2,2,2,2,2,3,5,10,20,30)
post_race_24 = c(-5,-2,-1,0,0,0,1,1,1,1,2,3)
y = c(pre_race, post_race_0, post_race_24)
time = rep(c('pre','0hr post', '24hr post'), each = 12)
x = rep(as.factor(1), length(y))
testdata <- data.frame(x, y, time)
library(ggthemes)
library(ggplot2)
library(gghalves)
ggplot(data = testdata, aes(x = x, y = y))+
geom_half_violin(aes(fill= time), position = "identity", scale = 'area', color = NA, alpha = 0.5, trim = F) +
stat_summary(fun = median, geom = 'point', aes(fill = time, group = time), color = 'black', shape = 23,
size = 4, position = position_nudge(-.05), alpha = 0.8)+
scale_color_tableau(palette = 'Classic 10')+
scale_fill_tableau(palette = 'Classic 10')+
scale_y_continuous('AKI RISK')+
scale_x_discrete(NULL)+
theme_classic()+
theme(text = element_text(size = 16, face = 'bold', color = 'black'),
axis.text = element_text(color = 'black'),
axis.line = element_line(size = 1),
axis.ticks = element_line(size = 1),
axis.text.x = element_blank())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment