# Basic boxplot with Seaborn

This page aims at explaining how to plot a basic boxplot with seaborn thanks to the boxplot() function. In a similar way as violinplots, one can use boxplots to differentiate groups based on one numerical variable only, or to study a particular group through several numerical variables. We will go through three basic examples with the 'iris' dataset.

## One single numerical variable

The simplest form of boxplot: analysis of the overall distribution of a single numerical variable in an entire dataset.

``````# libraries & dataset
import seaborn as sns
import matplotlib.pyplot as plt
# set a grey background (use sns.set_theme() if seaborn version 0.11.0 or above)
sns.set(style="darkgrid")

sns.boxplot(y=df["sepal_length"])
plt.show()``````

## Several numerical variables

If you intend to add more information in a single figure, you can also visualize several numerical variables distributions by setting the `data` argument and specifying a dataset with several numerical columns.

``````# libraries & dataset
import seaborn as sns
import matplotlib.pyplot as plt
# set a grey background (use sns.set_theme() if seaborn version 0.11.0 or above)
sns.set(style="darkgrid")

sns.boxplot(data=df.loc[:, ['sepal_length', 'sepal_width']])
plt.show()``````

## One numerical variable and several groups

Depending on your data, you may want to have a better understanding of the distribution of a given variable between two or more groups. You can do so by specifying the 'x' parameter in the boxplot() function.

``````# libraries & dataset
import seaborn as sns
import matplotlib.pyplot as plt
# set a grey background (use sns.set_theme() if seaborn version 0.11.0 or above)
sns.set(style="darkgrid")

sns.boxplot(x=df["species"], y=df["sepal_length"])
plt.show()``````

Violin

Density

Histogram

Boxplot

Ridgeline

## Contact & Edit

👋 This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message onTwitter, or send an email pasting `yan.holtz.data` with `gmail.com`.

Violin

Density

Histogram

Boxplot

Ridgeline

Scatterplot

Heatmap

Correlogram

Bubble

Connected Scatter

2D Density

Barplot

Wordcloud

Parallel

Lollipop

Circular Barplot

Treemap

Venn Diagram

Donut

Pie Chart

Dendrogram

Circular Packing

Line chart

Area chart

Stacked Area

Streamgraph

Timeseries

Map

Choropleth

Hexbin

Cartogram

Connection

Bubble

Chord Diagram

Network

Sankey

Arc Diagram

Edge Bundling

Colors

Interactivity

Animation

Cheat sheets

Caveats

3D