Visual Storytelling with Seaborn

Using Seaborn to Improve Your Data Visualizations

Reilly Meinert
Jun 11 · 13 min read

Introduction

Plotting Numerical Variables

sns.relplot(x='ShareWomen', y = 'Median', data = df)
plt.show()
sns.set_palette('Paired', 10)sns.relplot(x='ShareWomen', y='Median', hue = 'Major_category',
             data = df)
plt.title('Median Salary vs Share of Women in a Particular Major')
plt.show()
sns.relplot(x='ShareWomen', y='Median', hue = 'Major_category',
             style = 'Major_category', data = df)
sns.relplot(x='ShareWomen', y='Median', hue = 'Total', data = df)
plt.title('Median Salary vs Share of Women in a Particular Major')
plt.show()
sns.relplot(x='ShareWomen', y='Median', hue = 'Major_category', 
             size = 'Total', sizes = (15, 200), data = df)
plt.title('Median Salary vs Share of Women in a Particular Major')
plt.show()
sns.relplot(x= 'ShareWomen', y = 'Women', kind = 'line', data = df)
plt.title('Share of Women vs Total Women in a Particular Major')
plt.show()
sns.lmplot(x = 'ShareWomen', y='Median', data = df)
plt.show()

Plotting Categorical Variables

sns.catplot(x = 'Major_category', y = 'Median', data = df)
plt.title('Median Salary of Different Major Categories')
plt.show()
#Option 1sns.catplot(x = 'Median', y = 'Major_category', data = df)
plt.title('Median Salary of Different Major Categories')
plt.show()#Option 2sns.catplot(x = 'Major_category', y = 'Median', data = df)
plt.xticks(rotation = 90)
plt.show()
Option 1 (left) & Option 2 (right)
sns.catplot(x = 'Major_category', y = 'Median', hue = 'Gender Majority', data = df)
plt.title('Median Salary of Different Major Categories')
plt.xticks(rotation = 90)
plt.show()
# Option 1
sns.catplot(x = 'Major_category', y = 'Median', jitter = False,
             data = df)
plt.xticks(rotation = 90)
plt.show()# Option 2
sns.catplot(x = 'Major_category', y = 'Median', kind = 'swarm', 
            data = df)
plt.xticks(rotation = 90)
plt.show()
Option 1 (left) & Option 2 (right)
sns.catplot(x = 'Major_category', y = 'Median', kind = 'box', data = df)
plt.xticks(rotation = 90)
plt.show()
# Boxen Plot
sns.catplot(x = 'Major_category', y = 'Median', kind = 'boxen', 
             data = df)
plt.title('Boxen Plot')
plt.xticks(rotation = 90)
plt.show()# Violin Plot
sns.catplot(x = 'Major_category', y = 'Median', kind = 'violin',   
            data = df)
plt.title('Violin Plot')
plt.xticks(rotation = 90)
plt.show()
sns.catplot(x = 'Major_category', y = 'Median', kind = 'violin', 
            hue = 'Gender Majority', split = 'True', data = df)
plt.xticks(rotation = 90)
plt.show()

Conclusion

The Startup

Medium's largest active publication, followed by +469K people. Follow to join our community.

403

403 claps
Reilly Meinert

Written by

Statistics & Computer Science student at the University of Virginia https://www.linkedin.com/in/reilly-meinert-437223156/

The Startup

Medium's largest active publication, followed by +469K people. Follow to join our community.