In [ ]:
#summarize the relationship between two numeric variables via python
In [ ]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
In [ ]:
df= pd.read_csv('winequality.csv')
df.head()
Out[ ]:
fixed acidity volatile acidity citric acid residual sugar chlorides free sulfur dioxide total sulfur dioxide density pH sulphates alcohol quality
0 7.4 0.70 0.00 1.9 0.076 11.0 34.0 0.9978 3.51 0.56 9.4 5
1 7.8 0.88 0.00 2.6 0.098 25.0 67.0 0.9968 3.20 0.68 9.8 5
2 7.8 0.76 0.04 2.3 0.092 15.0 54.0 0.9970 3.26 0.65 9.8 5
3 11.2 0.28 0.56 1.9 0.075 17.0 60.0 0.9980 3.16 0.58 9.8 6
4 7.4 0.70 0.00 1.9 0.076 11.0 34.0 0.9978 3.51 0.56 9.4 5
In [ ]:
# display the relationship between fixed acidity and alcohol
In [ ]:
plt.figure(figsize=(5,3))
sns.scatterplot(data=df, x='fixed acidity', y='alcohol')
#plt.title('Relationship between Fixed Acidity and Alcohol')
#plt.xlabel('Fixed Acidity')
#plt.ylabel('Alcohol')
plt.show()
No description has been provided for this image
In [ ]:
#histplot
plt.figure(figsize=(5,3))
sns.histplot(data=df, x='fixed acidity', y='alcohol')
plt.show()
No description has been provided for this image
In [ ]:
#kdeplot
plt.figure(figsize=(5,3))
sns.kdeplot(data=df, x='fixed acidity', y='alcohol')
plt.show()
No description has been provided for this image
In [ ]:
#stacking technique
plt.figure(figsize=(5,3))
#sns.histplot(data=df, x='fixed acidity', y='alcohol')
sns.scatterplot(data=df, x='fixed acidity', y='alcohol', color='skyblue')
sns.histplot(data=df, x='fixed acidity', y='alcohol', color ='lightblue', pthresh=0.2)
sns.kdeplot(data=df, x='fixed acidity', y='alcohol', color='lightgreen')
plt.show()
No description has been provided for this image
In [ ]:
#jointplot with regression line
#plt.figure(figsize=(5,3))
sns.jointplot(data=df, x='fixed acidity', y='alcohol', kind='reg')
plt.show()
No description has been provided for this image
In [ ]:
 
In [ ]:
#jointplot with hex
#plt.figure(figsize=(5,3))
sns.jointplot(data=df, x='fixed acidity', y='alcohol', kind='hex')
plt.show()
No description has been provided for this image
In [ ]:
# identify the relationship between sulphate and alcohol across quality
In [ ]:
plt.figure(figsize=(5,5))
sns.kdeplot(data=df, x='sulphates', y='alcohol', hue='quality', palette='bwr', levels=3)
plt.show()
No description has been provided for this image
In [ ]:
#donut chart
prod= ['iphone', 'ipad']
color= ['skyblue', 'grey']
sales= [300,100]
In [ ]:
plt.figure(figsize=(5,5))
plt.pie(sales, labels=prod, colors=color, autopct='%.1f%%', wedgeprops={'width': 0.5},
        startangle=90, explode=(0,0.1), shadow=True)
plt.show()
No description has been provided for this image
In [ ]: