Assuming we have a scatter plot showing much data like:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
x=np.random.normal(size=10000)
y=np.random.normal(size=10000)+x
df=pd.DataFrame({'X':x,'Y':y})
sns.scatterplot(data=df,x='X',y='Y')
Many points overlapped in a plot, it is not good for further analysis.
Here I will introduce how to handle this situation.
- Increase the transparency
sns.scatterplot(data=df,x='X',y='Y',alpha=0.2)
It shows more plots underline.
2. Adding contour lines
sns.scatterplot(data=df,x='X',y='Y',alpha=0.2)
sns.kdeplot(data=df,x='X',y='Y')
Contour lines are able to show different levels.
3. Density
sns.scatterplot(data=df,x='X',y='Y',alpha=0.2)
sns.kdeplot(data=df,x='X',y='Y',fill=True)
If there are multiple levels, filling in with colors is a good idea.
4. Density Heatmap
sns.scatterplot(data=df,x='X',y='Y',alpha=0.2)
sns.kdeplot(data=df,x='X',y='Y',fill=True, cmap='mako')
Thank you for reading.