I am trying to create a violin plot of results of a survey, and everything looks fine, expect for those cases where all respondents submitted the same answer. In these cases, vioplot displays nothing, and I changed from vioplot to boxplot to have at least a line where the answers are.
My code:
plot(1,1,xlim=c(0,10),ylim=range(c(x1,x2,x3,x4,x5,x6,x7,x8,x9)),type="n",
xlab="",ylab="",axes=FALSE)
axis(side = 1, at=2,label="")
axis(side = 1, at=5,label="")
axis(side = 1, at=8,label="")
axis(side=2)
vioplot(x1,at=1,col="blue",add=TRUE)
vioplot(x2,at=2,col="red",add=TRUE)
vioplot(x3,at=3,col="yellow",add=TRUE)
vioplot(x4,at=4,col="blue",add=TRUE)
vioplot(x5,at=5,col="red",add=TRUE)
vioplot(x6,at=6,col="yellow",add=TRUE)
boxplot(x7,at=7,col="blue", add=TRUE)
boxplot(x8,at=8,col="red",add=TRUE)
vioplot(x9,at=9,col="yellow",add=TRUE)
This is what it looks like with boxplot, using vioplot instead, the whole column is empty.
Any ideas what I am doing wrong and what the code should be like so that I can use a vioplot?