Boxplot using Seaborn in Python

Last Updated : 15 Jul, 2025

Boxplot is used to see the distribution of numerical data and identify key stats like minimum and maximum values, median, identifying outliers, understanding how data is distributed and can compare the distribution of data across different categories or variables. In Seaborn the seaborn.boxplot() function is used to plot it and in this article we will learn about it.

Lets see a example: We will use the tips dataset which is an inbuilt dataset. This dataset contains information about restaurant tips, total bill amount, tip amount, customer details like sex and day of the week etc. Also we will be using Seaborn and Matplotlib libraries for this.

Python
import seaborn as sns
import matplotlib.pyplot as plt

df = sns.load_dataset("tips")
sns.boxplot(x="day", y="tip", data=df)
plt.show()

Output:

box1

Syntax:

seaborn.boxplot(x=None, y=None, hue=None, data=None, color=None, palette=None, linewidth=None,**kwargs)

Parameters: 

  • x, y, hue: Inputs for plotting long-form data. 
  • data: Dataset for plotting. If x and y are absent this is interpreted as wide-form. 
  • color: Color for all of the elements.

Returns: It returns Axes object with the plot drawn on it. 

Example 1: Horizontal Boxplot of Total Bill

By changing the axis to x, we can plot distribution of the total bill in a horizontal format. This makes it easy to view data horizontally.

Python
import seaborn as sns
import matplotlib.pyplot as plt

df = sns.load_dataset("tips")
sns.boxplot(x=df["total_bill"])
plt.show()

Output: