How to display only median value in boxplot?

5.2k views Asked by At

I need to create a boxplot which displays the median value in it. Not on the axes but directly inside the plot.

I found this thread very useful: How to put values.. with the solution:

boxplot(X, horizontal = TRUE, axes = FALSE, staplewex = 1)
text(x = boxplot.stats(X)$stats, labels = boxplot.stats(X)$stats, y = 1.25)

However, it displays all values and I could not figure out a way to customize it.

1

There are 1 answers

0
germcd On

boxplot.stats(X)$stats[3] shows only the median

boxplot(X, horizontal = TRUE, axes = FALSE, staplewex = 1)
text(x = boxplot.stats(X)$stats[3], labels = boxplot.stats(X)$stats[3], y = 1.25)

Will only have the median as the label