How to remove outliers from Seaborn boxplot charts

In this article, I am going to show you how to remove outliers from Seaborn boxplots. First, I am going to plot a boxplot without modifications. Then, I will remove all of the outliers. In the end, I am going to restore outliers, but this time I am going to make them less prominent.

Boxplot with outliers

Let’s start with plotting the data I already have.

1
2
3
import seaborn as sb

sb.boxplot(x = 'Value', data = with_merged)

Boxplot without outliers

To remove the outliers from the chart, I have to specify the “showfliers” parameter and set it to false.

1
sb.boxplot(x = 'Value', data = with_merged, showfliers = False)

Change the outliers style

In the next example, I am going to change the size of the outliers markers to make them less distracting for people who look at the chart.

1
sb.boxplot(x = 'Value', data = with_merged, flierprops = dict(markerfacecolor = '0.50', markersize = 2))

Did you enjoy reading this article?
Would you like to learn more about leveraging AI to drive growth and innovation, software craft in data engineering, and MLOps?

Subscribe to the newsletter or add this blog to your RSS reader (does anyone still use them?) to get a notification when I publish a new essay!

Newsletter

Do you enjoy reading my articles?
Subscribe to the newsletter if you don't want to miss the new content, business offers, and free training materials.

Bartosz Mikulski

Bartosz Mikulski

  • MLOps engineer by day
  • AI and data engineering consultant by night
  • Python and data engineering trainer
  • Conference speaker
  • Contributed a chapter to the book "97 Things Every Data Engineer Should Know"
  • Twitter: @mikulskibartosz
  • Mastodon: @mikulskibartosz@mathstodon.xyz
Newsletter

Do you enjoy reading my articles?
Subscribe to the newsletter if you don't want to miss the new content, business offers, and free training materials.