This file contains hidden or 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
# Scatter Plot | |
plt.scatter(wines['sulphates'], wines['alcohol'], | |
alpha=0.4, edgecolors='w') | |
plt.xlabel('Sulphates') | |
plt.ylabel('Alcohol') | |
plt.title('Wine Sulphates - Alcohol Content',y=1.05) | |
# Joint Plot |
This file contains hidden or 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
# Using subplots or facets along with Bar Plots | |
fig = plt.figure(figsize = (10, 4)) | |
title = fig.suptitle("Wine Type - Quality", fontsize=14) | |
fig.subplots_adjust(top=0.85, wspace=0.3) | |
# red wine - wine quality | |
ax1 = fig.add_subplot(1,2, 1) | |
ax1.set_title("Red Wine") | |
ax1.set_xlabel("Quality") | |
ax1.set_ylabel("Frequency") | |
rw_q = red_wine['quality'].value_counts() |
This file contains hidden or 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
# Multi-bar Plot | |
cp = sns.countplot(x="quality", hue="wine_type", data=wines, | |
palette={"red": "#FF9999", "white": "#FFE888"}) |
This file contains hidden or 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
# facets with histograms | |
fig = plt.figure(figsize = (10,4)) | |
title = fig.suptitle("Sulphates Content in Wine", fontsize=14) | |
fig.subplots_adjust(top=0.85, wspace=0.3) | |
ax1 = fig.add_subplot(1,2, 1) | |
ax1.set_title("Red Wine") | |
ax1.set_xlabel("Sulphates") | |
ax1.set_ylabel("Frequency") | |
ax1.set_ylim([0, 1200]) |
This file contains hidden or 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
# Using multiple Histograms | |
fig = plt.figure(figsize = (6, 4)) | |
title = fig.suptitle("Sulphates Content in Wine", fontsize=14) | |
fig.subplots_adjust(top=0.85, wspace=0.3) | |
ax = fig.add_subplot(1,1, 1) | |
ax.set_xlabel("Sulphates") | |
ax.set_ylabel("Frequency") | |
g = sns.FacetGrid(wines, hue='wine_type', palette={"red": "r", "white": "y"}) | |
g.map(sns.distplot, 'sulphates', kde=False, bins=15, ax=ax) |
This file contains hidden or 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
# Box Plots | |
f, (ax) = plt.subplots(1, 1, figsize=(12, 4)) | |
f.suptitle('Wine Quality - Alcohol Content', fontsize=14) | |
sns.boxplot(x="quality", y="alcohol", data=wines, ax=ax) | |
ax.set_xlabel("Wine Quality",size = 12,alpha=0.8) | |
ax.set_ylabel("Wine Alcohol %",size = 12,alpha=0.8) |
This file contains hidden or 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
# Violin Plots | |
f, (ax) = plt.subplots(1, 1, figsize=(12, 4)) | |
f.suptitle('Wine Quality - Sulphates Content', fontsize=14) | |
sns.violinplot(x="quality", y="sulphates", data=wines, ax=ax) | |
ax.set_xlabel("Wine Quality",size = 12,alpha=0.8) | |
ax.set_ylabel("Wine Sulphates",size = 12,alpha=0.8) |
This file contains hidden or 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
# Scatter Plot with Hue for visualizing data in 3-D | |
cols = ['density', 'residual sugar', 'total sulfur dioxide', 'fixed acidity', 'wine_type'] | |
pp = sns.pairplot(wines[cols], hue='wine_type', size=1.8, aspect=1.8, | |
palette={"red": "#FF9999", "white": "#FFE888"}, | |
plot_kws=dict(edgecolor="black", linewidth=0.5)) | |
fig = pp.fig | |
fig.subplots_adjust(top=0.93, wspace=0.3) | |
t = fig.suptitle('Wine Attributes Pairwise Plots', fontsize=14) |
This file contains hidden or 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
# Visualizing 3-D numeric data with Scatter Plots | |
# length, breadth and depth | |
fig = plt.figure(figsize=(8, 6)) | |
ax = fig.add_subplot(111, projection='3d') | |
xs = wines['residual sugar'] | |
ys = wines['fixed acidity'] | |
zs = wines['alcohol'] | |
ax.scatter(xs, ys, zs, s=50, alpha=0.6, edgecolors='w') |
This file contains hidden or 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
# Visualizing 3-D numeric data with a bubble chart | |
# length, breadth and size | |
plt.scatter(wines['fixed acidity'], wines['alcohol'], s=wines['residual sugar']*25, | |
alpha=0.4, edgecolors='w') | |
plt.xlabel('Fixed Acidity') | |
plt.ylabel('Alcohol') | |
plt.title('Wine Alcohol Content - Fixed Acidity - Residual Sugar',y=1.05) |