Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add an asterix to a boxplot to represent significance?

I am trying to include an asterix on top or bottom of a box in boxplot graph that represent significance after performing the independent variable t-test evaluation. How can I add this to my graph?

like image 688
user1250704 Avatar asked Mar 05 '12 20:03

user1250704


People also ask

What does an asterisk (*) on a Boxplot represent?

Extreme outliers are marked with an asterisk (*) on the boxplot. Mild outliers are data points that are more extreme than than Q1 - 1.5 * IQR or Q3 + 1.5 * IQR, but are not extreme outliers.

How do you know if a Boxplot is statistically significant?

If your calculated t-statistic is larger than p = 0.05 t-critical value, then the difference between the means is statistically significant. You can reject the null hypothesis with no more than a 5% error rate and accept the alternative hypothesis.

What do dots in Boxplot mean?

Sometimes, the mean is also indicated by a dot or a cross on the box plot. The whiskers are the two lines outside the box, that go from the minimum to the lower quartile (the start of the box) and then from the upper quartile (the end of the box) to the maximum.

How do you add data points to a box plot?

After generating the box plot in graph builder you can right click the graph, select add, then select points. Alternatively, you can add the points on top of the box plot by dragging the icon with points (in the pallete above the graph) on top of the graph.


2 Answers

You can use text() to add simple symbols to custom location on the plot:

boxplot(c(1:10),ylim=c(0,12),axes=F)
text(11,"*",cex=2)

enter image description here

EDIT: In reply to @chl suggestion, here is the above application with a series of boxplots:

boxplot(count ~ spray,data = InsectSprays,axes=F,ylim=c(0,30))
text(c(25,23,-10,-10,-10,27),"*",cex=2)

enter image description here

like image 81
Geek On Acid Avatar answered Sep 22 '22 19:09

Geek On Acid


You can use text() and write at the corresponding location, if you know it beforehand; e.g.,

dfrm <- data.frame(y=rnorm(100, mean=10), x=gl(4, 25))
dfrm$y[dfrm$x==2] <- dfrm$y[dfrm$x==2]+2
boxplot(y ~ x, data=dfrm, ylim=c(min(dfrm$y)-.5, max(dfrm$y)+.5))
text(x=2, y=max(dfrm$y[dfrm$x==2]), "*", pos=3, cex=1.2)

Adapt x=2 to suit your needs.

Or you can use mtext to put the star outside the plotting region, like in

mtext("*", side=3, line=0, at=2, cex=1.2)
like image 24
chl Avatar answered Sep 23 '22 19:09

chl