r - How to control transparency (alpha) in ggplot violin plot's (dots) -
the following image
is created following code:
library(ggplot2) library(plyr) library(reshape) df<- structure(list(variable = structure(c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l), .label = "bcd.id.ln", class = "factor"), value = c(1.133, 1.068, 1.01, 0.943, 1.048, 1.053, 0.999, 1.014, 1.149, 1.068, 0.898, 1.008, 0.976, 1.029, 0.95, 0.986, 1.102, 1.007, 1.08, 1.219), fc_log = c(0.180147861158429, 0.094911647025467, 0.0143552929770701, -0.0846703239869906, 0.0676387168753633, 0.0745054363636298, -0.00144341686966872, 0.0200576523412535, 0.200378797984026, 0.094911647025467, -0.15521264992094, 0.0114956388378294, -0.0350469470992008, 0.0412429822318813, -0.0740005814437769, -0.0203404482841755, 0.140124223909071, 0.0100636833446975, 0.111031312388744, 0.285698125958125), len = c(26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l, 26654l ), ecd = c(0.77027838223156, 0.633263300067532, 0.462219554288287, 0.290425452089743, 0.577361746829744, 0.592744053425377, 0.431417423276056, 0.473737525324529, 0.791888647107376, 0.633263300067532, 0.203909356944549, 0.456929541532228, 0.367524574172732, 0.519246642155024, 0.3059953477902, 0.395137690402941, 0.713251294364823, 0.453365348540557, 0.663840324153973, 0.865123433630975)), .names = c("variable", "value", "fc_log", "len", "ecd"), row.names = c(na, 20l), class = "data.frame") ggplot(df, aes(x = factor(variable), y=fc_log)) + geom_violin(adjust=.5, trim=false, fill='#a4a4a4', color="darkred" ) + geom_boxplot(width=0.1) + theme_minimal() + ylab("log2(fold change)") + xlab("")
as stated in image, how can make dots transparent?
use outlier.colour= geom_boxplot rgb , transparency argument ('alpha'):
geom_boxplot(width=0.1, outlier.colour=rgb(.5,.5,.5, 0.5) ) + theme_minimal() +
Comments
Post a Comment