forked from VizWizard/BoxPlotR.shiny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoxPlotR_functions.R
24 lines (23 loc) · 1023 Bytes
/
BoxPlotR_functions.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# pointType - 0 = normal; 2 = jittered
# Add data points for specified columns in 'jittered' arrangement
jittered.points<-function(D, myHorizontal=FALSE, pointType, pointColors, pointTransparency, pointSize){
# normal boxplots
if(myHorizontal){
for (i in c(1:ncol(D))){
if(pointType==0){
points(D[,i], rep(i, nrow(D)), col=rgb(t(col2rgb(pointColors[i])), max=255, alpha=255*(pointTransparency/100)), pch=16, cex=pointSize)
} else {
points(D[,i], jitter(rep(i, nrow(D)), amount=0.25), col=rgb(t(col2rgb(pointColors[i])), max=255, alpha=255*(pointTransparency/100)), pch=16, cex=pointSize)
}
}
} else {
# horizontal boxplots
for (i in c(1:ncol(D))){
if(pointType==0){
points(rep(i, nrow(D)), D[,i], col=rgb(t(col2rgb(pointColors[i])), max=255, alpha=255*(pointTransparency/100)), pch=16, cex=pointSize)
} else {
points(jitter(rep(i, nrow(D)), amount=0.25), D[,i], col=rgb(t(col2rgb(pointColors[i])), max=255, alpha=255*(pointTransparency/100)), pch=16, cex=pointSize)
}
}
}
}