Created
September 23, 2018 18:37
-
-
Save JonnyCBB/449fcd61ed3aa54e16f4d87f8bcd25bf to your computer and use it in GitHub Desktop.
Creating a boxplot using matplotlib's standard boxplot function and Seaborn's boxplot function
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
import matplotlib.pyplot as plt | |
import seaborn as sns | |
tips = sns.load_dataset("tips") # Load data | |
fig, axs = plt.subplots(1, 2) # Create subplots | |
# Boxplot with matplotlib | |
tips_box = [tips.query('day == @day')['total_bill'] for day in tips.day.unique()] | |
axs[0].boxplot(tips_box, labels=tips.day.unique()) | |
# Boxplot with Seaborn | |
sns.boxplot(x="day", y="total_bill", data=tips, ax=axs[1]) | |
fig.suptitle('Boxplot', fontsize=18) # | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment