Last active
January 14, 2023 17:10
-
-
Save muhammadanas0716/23c071b32ebf9f0b16bfddc8cbb6ff5c to your computer and use it in GitHub Desktop.
Another option to avoid the problem of points overlap is the increase the size of the dot depending on how many points lie in that spot. So, larger the size of the point more is the concentration of points around that.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Imports | |
import numpy as np | |
import pandas as pd | |
import matplotlib as mpl | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
# Import Data | |
df = pd.read_csv("https://raw.githubusercontent.com/selva86/datasets/master/mpg_ggplot2.csv") | |
df_counts = df.groupby(['hwy', 'cty']).size().reset_index(name='counts') | |
# Draw Stripplot | |
fig, ax = plt.subplots(figsize=(16,10), dpi= 80) | |
sns.stripplot(x=df_counts.cty, y=df_counts.hwy, sizes=(df_counts.counts*20), hue=df_counts.counts, ax=ax) | |
# Decorations | |
plt.title('Counts Plot - Size of circle is bigger as more points overlap', fontsize=22) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for some reason it didn't work for me so I changed it to