Matplotlib boxplot without outliers

Question:

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

Asked By: Didac Busquets

||

Answers:

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.

Answered By: tom10
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.