Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R boxplot and stripchart side-by-side in 1 figure

Is it possible to plot a boxplot and a stripchart next to each other in the same figure? If I run this code, the stripchart overrides the boxplots. What i actually want is that they lay next to each other. In hat way a figure with 10 column on the x-as will be formed. Is that possible?

boxplot(doubles[1:5,])
stripchart(doubles[6:10,],add=TRUE,vertical=TRUE, pch=19)

enter image description here

like image 558
Lisann Avatar asked Jan 18 '23 03:01

Lisann


1 Answers

Some example of you data would be good, but the easiest option is probably:

 #random data corresponding to your 5 columns    
 x <- data.frame(V = rnorm(100), W = rnorm(100), X = rnorm(100), Y = rnorm(100), 
     Z = rnorm(100))
 #remove axis with 'axes=F', define wider x-limits with 'xlim' 
 stripchart(x[1:5,],vertical=TRUE, pch=19,xlim=c(1,6),axes=F)
 #add boxplots next to stripchart, decrease width with 'boxwex'
 boxplot(x[1:5,],add=T,at=1.5:5.5,boxwex=0.25,axes=F)
 #add custom x axis
 axis(1,at=1.25:5.25,labels=names(x))

enter image description here

like image 131
Geek On Acid Avatar answered Jan 29 '23 04:01

Geek On Acid