Matplotlib boxplot without outliers

Didac Busquets picture Didac Busquets · Feb 25, 2014 · Viewed 48.7k times · Source

Is there any way of hiding the outliers when plotting a boxplot in matplotlib (python)?

I'm using the simplest way of plotting it:

  from pylab import *
  boxplot([1,2,3,4,5,10])
  show()

This gives me the following plot:

(I cannot post the image because I have not enough reputation, but basically it is a boxplot with Q1 at y=1, Q3 at y=5, and the outlier at y=10)

I would like to remove the outlier at y=10, so that the plot only shows from Q1 to Q3 (in this case from 1 to 5).

Answer

tom10 picture tom10 · Feb 26, 2014

In current versions of matplotlib you can do:

boxplot([1,2,3,4,5,10], showfliers=False)

or

boxplot([1,2,3,4,5,10], sym='')

In older versions, only the second approach will work.

The docs for boxplot do mention this, btw as, "Enter an empty string (‘’) if you don’t want to show fliers.", though, at least for myself, "outliers" is the more familiar word.