Seaborn has been around for a long time.
I bet it is one of the most well-known and used libraries for data visualization because it is beginner-friendly, allowing non-statisticians to create powerful charts that help extract information backed by statistics.
I'm not a statistician. My interest in the topic comes from Data Science. I need to learn statistical concepts to do my job better. That's why I love having easy access to histograms, confidence intervals, and linear regressions with very little code.
Seaborn's syntax is very basic: sns.type_of_plot(data, x, y)
. Using that simple template, we can create many different visualizations, such as barplot
, histplot
, scatterplot
, lineplot
, boxplot
and more.
But this post is not to talk about that. These are other types of enhanced visualizations that can make a difference in your analysis.
Let's see what they are.
To create these visualizations and code along with this exercise, simply import seaborn using import seaborn as sns
.
The data set used here is Student performancecreated by Paulo Cortez and donated to the UCI Repository under the Creative Commons license. It can be imported directly into Python with the following code.
# Install UCI Repo
pip install ucimlrepo# Loading a dataset
from ucimlrepo import fetch_ucirepo
# fetch dataset
student_performance = fetch_ucirepo(id=320)
# data (as pandas dataframes)
X = student_performance.data.features
y = student_performance.data.targets
# Gather X and Y for visualizations
df = pd.concat((X,y), axis=1)
df.head(3)
Now let's talk about the 5 visualizations.
1. Bare plot
The first plot chosen is stripplot
. And you'll quickly see why this is interesting. If we use this simple line of code, it will show the following visualization.
# Plot
sns.stripplot(data=df);