Skip to content

Instantly share code, notes, and snippets.

@lesutton
Last active October 1, 2022 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lesutton/eebec37ed1a5bc256860acddf5cc6942 to your computer and use it in GitHub Desktop.
Save lesutton/eebec37ed1a5bc256860acddf5cc6942 to your computer and use it in GitHub Desktop.
Box Plot
import seaborn as sns
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import warnings
import numpy as np
tips_data=sns.load_dataset('tips')
tips_data.info
plt.boxplot(tips_data.total_bill)
plt.text(x=1.1,y=tips_data.total_bill.min(),s='min')
plt.text(x=1.1,y=tips_data.total_bill.quantile(.25),s='Q1')
plt.text(x=1.1,y=tips_data.total_bill.median(),s='median (Q2)')
plt.text(x=1.1,y=tips_data.total_bill.quantile(.75),s='Q3')
plt.text(x=1.1,y=tips_data.total_bill.max(),s='max')
max_val = tips_data.total_bill.max()
offset_val = max_val *.10
print(max_val)
plt.annotate('Outliers',xy = (0.97,max_val-offset_val),xytext=(0.7,max_val-offset_val), arrowprops = dict(facecolor='black',arrowstyle = 'simple'))
plt.title('Boxplot of Total Bill Amount')
plt.ylabel('Total Bill')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment