Last active
October 1, 2022 19:35
-
-
Save lesutton/eebec37ed1a5bc256860acddf5cc6942 to your computer and use it in GitHub Desktop.
Box Plot
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 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