Manish Manish - 3 months ago 29
R Question

How to put values of on box plot for median, Ist quartlie and last quartlle?

How to put values on box plot and control its width?


I need to write values for min,max, Ist quartlie, median and last quartlie. How can i put it there.


You can use horizontal = TRUE get a horizontal boxplot and axes = FALSE to remove the axes. staplewex = 1 sets the staple width the same as the box width

Then you can use fivenum to return the statistics used to create the boxplot and use these as text labels, fiddling with the y value until you have what you want

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

enter image description here

Note that i've inserted a 3 for the value missing in your example data X