Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Boxplot | Categorical Plot Types
Deep Dive into the seaborn Visualization

book
Boxplot

A boxplot is a standardized way of displaying the distribution of data based on a five-number summary (minimum, first quartile (Q1), median, third quartile (Q3), and maximum).

It can tell you about your outliers and what their values are. It can also tell you if your data is symmetrical, how tightly your data is grouped, and if and how your data is skewed.

carousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-img
Task

Swipe to start coding

  1. Set the 'ticks' style with the 'grey' figure.facecolor and 'white' x- & yticks.
  2. Create the boxplot using the seaborn library:
  • Set the x parameter equals the 'distance';
  • Set the y parameter equals the 'method';
  • Set the linewidth parameter equals 2;
  • Set the saturation parameter equals 0.4;
  • Set the 'vlag' palette.

Solution

import warnings

# Ignore all warnings
warnings.filterwarnings('ignore')

# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/planets.csv')

# Set the 'ticks' style with the 'white' x & y ticks and 'grey' facecolor
sns.set_style('ticks', {'xtick.color' : 'white',
'ytick.color' : 'white',
'figure.facecolor' : 'grey'})
# Create a boxplot
sns.boxplot(# Set the x
x = 'distance',
# Set the y
y = 'method',
# Setting the width
width = 0.6,
# Set the linewidth
linewidth = 2,
# Set the saturation
saturation = 0.4,
# Set the palette
palette = 'vlag',
# Setting the data
data = df)

# Displaying the plot
plt.show()

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 3
single

single

import warnings

# Ignore all warnings
warnings.filterwarnings('ignore')

# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/planets.csv')

# Set the 'ticks' style with the 'white' x & y ticks and 'grey' facecolor
___.___('___', {'xtick.color' : '___',
'___.___' : '___',
'___' : '___'})
# Create a boxplot
___(# Set the x
x = '___',
# Set the y
y = '___',
# Setting the width
width = 0.6,
# Set the linewidth
___,
# Set the saturation
___ = 0.4,
# Set the palette
___,
# Setting the data
data = df)

# Displaying the plot
plt.show()

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt