Manish - 3 months ago 29

R Question

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

`X<-c(1,2,,3,4,4,5,5,6,6,6,6,6,7)`

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

Answer

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)
```

Note that i've inserted a `3`

for the value missing in your example data `X`