I'm trying to reproduce the following image image http://www.davidzeleny.net/wiki/lib/exe/fetch.php/vizualizace:figures:boxplots-jitter-rdbu-colors.png?cache=
The code I'm using is roughly this:
library(RColorBrewer)
library(reshape2)
a=rnorm(100, mean=1)
b=rnorm(100, mean=0, sd=1)
ab=data.frame(a,b)
melt=melt(ab)
bpColor=brewer.pal(4, 'RdBu')
boxplot(melt$value ~ melt$variable, notch=T, col=c(bpColor[1], bpColor[4]), outline=F, varwidth=T)
stripchart(melt$value ~ melt$variable, add=T, vertical=T, pch=21,
bg=bpColor[2:3][melt$variable], method='jitter', jitter=0.02)
What I'm getting from this is almost the same except for the color of the stripchart points
my_image http://is.muni.cz/de/256262/Rplot.png
How should I edit my code in order to reproduce the proper coloring? I thought, that
bg=bpColor[2:3][melt$variable]
would do the job, however I'm getting this output, if I would erase the [] brackets I got two colors, but mixed within the groups. Thank you advance for your help.