Why do means appear outside the boxplot? I have plotted the boxplots of the distributions of certain groups and I was bewildered to see that the means appear outside the boxplots. How could this be explained?  
Since boxplots are a mainstream visualization technique of distributions, I felt that my question fit the scope of this Forum.
My code is the following:
fun_mean <- function(x){
  return(data.frame(y=round(mean(x), digits = 3),label=mean(x,na.rm=T)))}

ggplot(my_data, aes(x = as.factor(viotiko), y = pd_1year, fill = as.factor(viotiko))) + geom_boxplot() +
  labs(title="Does the PD differ significantly by 'Viotiko' group?",x="Viotiko Group", y = "PD (pd_1year)") +
  coord_cartesian(ylim = c(0,0.05))  + stat_summary(fun.y = mean, geom="point",colour="darkred", size=3) +
  stat_summary(fun.data = fun_mean, geom="text", vjust=-0.7)

The boxplot is the one shown below (I apologize for the cluttering of the text depicting means but I am still searching a way to repair this.)

Your advice will be appreciated.
 A: The box bounds are at the upper and lower hinges, which may be thought of as a particular definition of sample upper and lower quartiles.
It's quite easy for sample means to fall above the upper quartile or below the lower quartile. Note in particular that if you have a few large observations that can pull the mean up without necessarily affecting the quartiles at all. (Samples where this tends to happen would typically be described as skewed -- specifically, when you have enough large values to pull the mean above the upper quartile, you'd usually describe it as right-skew.)
Look what happens with these 9 numbers as a sample:
 1   2    3    4    5    6   7   8    9

The lower hinge is 3, the upper hinge is 7 and the mean and median are both 5. Now move those two largest observations up to 13 and 23 (say)
 1   2    3    4    5    6   7   13   23

Now the median and the hinges/quartiles are the same as before (3,5,7) but the mean is now just above 7, so it would fall outside the box. 

[The boxplot of the top sample is symmetric, so the mean is right in the middle. The lower boxplot has had its two largest values moved up, which affects the mean, and now it appears to be right-skewed, in a way that leaves the mean "outside the box". Similarly, if the lowest values were sufficiently low, they could pull the mean below the box.]
If you move the two largest observations (or even just the largest one) higher still, the mean can be pulled as far away from the box as you like - it can be any number of interquartile ranges above the upper quartile. The median and hinges (/quartiles) are not affected by extreme values (as long as there's no more than $\lfloor (n-1)/4 \rfloor$ of them), but the mean certainly is. 
A: The bounds of a boxplot are the lower and upper quartiles of the data, so the mean will be outside the boxplot so long as it's under the lower quartile or over the upper quartile. A simple example is the vector $(0, 1, 2, 3, 100)$. Here, the quartiles are $(1, 2, 3)$, but the mean is $21.2$, which is much greater than $3$.
