🚀
Seaborn
00 Scatter Plots
++++
Data Science
May 2026×Notebook lesson

Notebook converted from Jupyter for blog publishing.

00-Scatter-Plots

Driptanil Datta
Driptanil DattaSoftware Developer

Scatter Plots

Scatter plots can show how different features are related to one another, the main theme between all relational plot types is they display how features are interconnected to each other. There are many different types of plots that can be used to show this, so let's explore the scatterplot() as well as general seaborn parameters applicable to other plot types.


Data

We'll use some generated data from: http://roycekimmons.com/tools/generated_data (opens in a new tab)

import pandas as pd
import seaborn as sns
df = pd.read_csv("dm_office_sales.csv")
df.head()
HTML
MORE
division
level of education
training level
work experience
salary
df.info()
STDOUT
MORE
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1000 entries, 0 to 999
Data columns (total 6 columns):
 #   Column              Non-Null Count  Dtype 
---  ------              --------------  ----- 

Scatterplot

sns.scatterplot(x='salary',y='sales',data=df)
RESULT
<matplotlib.axes._subplots.AxesSubplot at 0x2089e370088>
PLOT
Output 1

Connecting to Figure in Matplotlib

Note how matplotlib is still connected to seaborn underneath (even without importing matplotlib.pyplot), since seaborn itself is directly making a Figure call with matplotlib. We can import matplotlib.pyplot and make calls to directly effect the seaborn figure.

import matplotlib.pyplot as plt
plt.figure(figsize=(12,8))
sns.scatterplot(x='salary',y='sales',data=df)
RESULT
<matplotlib.axes._subplots.AxesSubplot at 0x2089fb16a08>
PLOT
Output 2

Seaborn Parameters

The hue and palette parameters are commonly available around many plot calls in seaborn.

hue

Color points based off a categorical feature in the DataFrame

plt.figure(figsize=(12,8))
sns.scatterplot(x='salary',y='sales',data=df,hue='division')
RESULT
<matplotlib.axes._subplots.AxesSubplot at 0x2089fb0fe88>
PLOT
Output 3
plt.figure(figsize=(12,8))
sns.scatterplot(x='salary',y='sales',data=df,hue='work experience')
RESULT
<matplotlib.axes._subplots.AxesSubplot at 0x2089fc3d848>
PLOT
Output 4

Choosing a palette from Matplotlib's cmap: https://matplotlib.org/tutorials/colors/colormaps.html (opens in a new tab)

plt.figure(figsize=(12,8))
sns.scatterplot(x='salary',y='sales',data=df,hue='work experience',palette='viridis')
RESULT
<matplotlib.axes._subplots.AxesSubplot at 0x2089fcbbdc8>
PLOT
Output 5

Scatterplot Parameters

These parameters are more specific to the scatterplot() call

size

Allows you to size based on another column

plt.figure(figsize=(12,8))
sns.scatterplot(x='salary',y='sales',data=df,size='work experience')
RESULT
<matplotlib.axes._subplots.AxesSubplot at 0x2089fcb7188>
PLOT
Output 6

Use s= if you want to change the marker size to be some uniform integer value

plt.figure(figsize=(12,8))
sns.scatterplot(x='salary',y='sales',data=df,s=200)
RESULT
<matplotlib.axes._subplots.AxesSubplot at 0x208a00c1708>
PLOT
Output 7
plt.figure(figsize=(12,8))
sns.scatterplot(x='salary',y='sales',data=df,s=200,linewidth=0,alpha=0.2)
RESULT
<matplotlib.axes._subplots.AxesSubplot at 0x208a077b908>
PLOT
Output 8

style

Automatically choose styles based on another categorical feature in the dataset. Optionally use the markers= parameter to pass a list of marker choices based off matplotlib, for example: ['*','+','o']

plt.figure(figsize=(12,8))
sns.scatterplot(x='salary',y='sales',data=df,style='level of education')
RESULT
<AxesSubplot:xlabel='salary', ylabel='sales'>
PLOT
Output 9
plt.figure(figsize=(12,8))
# Sometimes its nice to do BOTH hue and style off the same column
sns.scatterplot(x='salary',y='sales',data=df,style='level of education',hue='level of education',s=100)
RESULT
<AxesSubplot:xlabel='salary', ylabel='sales'>
PLOT
Output 10

Exporting a Seaborn Figure

plt.figure(figsize=(12,8))
sns.scatterplot(x='salary',y='sales',data=df,style='level of education',hue='level of education',s=100)
 
# Call savefig in the same cell
plt.savefig('example_scatter.jpg')
PLOT
Output 11


Drip

Driptanil Datta

Software Developer

Building full-stack systems, one commit at a time. This blog is a centralized learning archive for developers.

Legal Notes
Disclaimer

The content provided on this blog is for educational and informational purposes only. While I strive for accuracy, all information is provided "as is" without any warranties of completeness, reliability, or accuracy. Any action you take upon the information found on this website is strictly at your own risk.

Copyright & IP

Certain technical content, interview questions, and datasets are curated from external educational sources to provide a centralized learning resource. Respect for original authorship is maintained; no copyright infringement is intended. All trademarks, logos, and brand names are the property of their respective owners.

System Operational

© 2026 Driptanil Datta. All rights reserved.