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?
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.
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.
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.
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.
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)
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)
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With