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).
Creating Box Plotpyplot module of matplotlib library provides boxplot() function with the help of which we can create box plots. The data values given to the ax. boxplot() method can be a Numpy array or Python list or Tuple of arrays. Let us create the box plot by using numpy.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With