It is trivial to create a boxplot in R with a full dataset. However, with limited access to the whole dataset, I just have 5 data point at min, 25%, 50% ,75%, and max. So is there any easy way to reproduce the boxplot with only these 5 values?

  • 1
    $\begingroup$ What about boxplot(your.five.data.points)? $\endgroup$ Apr 1, 2014 at 23:44

1 Answer 1


It's still pretty trivial. You can't reproduce the whiskers of a default boxplot effectively if the minimum and maximum values exceed Tukey's fences, but the box itself should remain unaltered. E.g., with x=rnorm(9999), compare boxplot(x) vs. boxplot(quantile(x)):

$\leftarrow$ full dataset vs. your five values $\rightarrow$

  • 2
    $\begingroup$ boxplot(fivenum(x)) is a lot shorter than boxplot(c(min(x),quantile(x,c(.25,.5,.75)),max(x))) (though if the quartiles don't match the definition of hinge in fivenum that might not be suitable) $\endgroup$
    – Glen_b
    Apr 2, 2014 at 5:20
  • $\begingroup$ Slick! Updated. $\endgroup$ Apr 2, 2014 at 5:22
  • 1
    $\begingroup$ See the edit to my comment; your original has the advantage of being able to use any of the 9 definitions of quantiles. Then again, boxplot(quantile(x)) would work in place of fivenum and probably matches the original post better; I'm just used to associating boxplots with fivenum. $\endgroup$
    – Glen_b
    Apr 2, 2014 at 5:25
  • $\begingroup$ Wow. Never knew that one either! We'll go with that one then. $\endgroup$ Apr 2, 2014 at 5:39
  • $\begingroup$ Yep. In large samples like that you can't see any difference between them, of course $\endgroup$
    – Glen_b
    Apr 2, 2014 at 5:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.