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 categorical data using bar plots | |
# leveraging the concepts of hue and facets | |
fc = sns.factorplot(x="quality", hue="wine_type", col="quality_label", | |
data=wines, kind="count", | |
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
# Visualizing 3-D mix data using scatter plots | |
# leveraging the concepts of hue for categorical dimension | |
jp = sns.pairplot(wines, x_vars=["sulphates"], y_vars=["alcohol"], size=4.5, | |
hue="wine_type", palette={"red": "#FF9999", "white": "#FFE888"}, | |
plot_kws=dict(edgecolor="k", linewidth=0.5)) | |
# we can also view relationships\correlations as needed | |
lp = sns.lmplot(x='sulphates', y='alcohol', hue='wine_type', | |
palette={"red": "#FF9999", "white": "#FFE888"}, | |
data=wines, fit_reg=True, legend=True, |
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 mix data using kernel density plots | |
# leveraging the concepts of hue for categorical dimension | |
ax = sns.kdeplot(white_wine['sulphates'], white_wine['alcohol'], | |
cmap="YlOrBr", shade=True, shade_lowest=False) | |
ax = sns.kdeplot(red_wine['sulphates'], red_wine['alcohol'], | |
cmap="Reds", shade=True, shade_lowest=False) |
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 mix data using violin plots | |
# leveraging the concepts of hue and axes for > 1 categorical dimensions | |
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 4)) | |
f.suptitle('Wine Type - Quality - Acidity', fontsize=14) | |
sns.violinplot(x="quality", y="volatile acidity", | |
data=wines, inner="quart", linewidth=1.3,ax=ax1) | |
ax1.set_xlabel("Wine Quality",size = 12,alpha=0.8) | |
ax1.set_ylabel("Wine Volatile Acidity",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
# Visualizing 3-D mix data using box plots | |
# leveraging the concepts of hue and axes for > 1 categorical dimensions | |
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 4)) | |
f.suptitle('Wine Type - Quality - Alcohol Content', fontsize=14) | |
sns.boxplot(x="quality", y="alcohol", hue="wine_type", | |
data=wines, palette={"red": "#FF9999", "white": "white"}, ax=ax1) | |
ax1.set_xlabel("Wine Quality",size = 12,alpha=0.8) | |
ax1.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
# Visualizing 4-D mix data using scatter plots | |
# leveraging the concepts of hue and depth | |
fig = plt.figure(figsize=(8, 6)) | |
t = fig.suptitle('Wine Residual Sugar - Alcohol Content - Acidity - Type', fontsize=14) | |
ax = fig.add_subplot(111, projection='3d') | |
xs = list(wines['residual sugar']) | |
ys = list(wines['alcohol']) | |
zs = list(wines['fixed acidity']) | |
data_points = [(x, y, z) for x, y, z in zip(xs, ys, zs)] |
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 4-D mix data using bubble plots | |
# leveraging the concepts of hue and size | |
size = wines['residual sugar']*25 | |
fill_colors = ['#FF9999' if wt=='red' else '#FFE888' for wt in list(wines['wine_type'])] | |
edge_colors = ['red' if wt=='red' else 'orange' for wt in list(wines['wine_type'])] | |
plt.scatter(wines['fixed acidity'], wines['alcohol'], s=size, | |
alpha=0.4, color=fill_colors, edgecolors=edge_colors) | |
plt.xlabel('Fixed Acidity') |
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 4-D mix data using scatter plots | |
# leveraging the concepts of hue and facets for > 1 categorical attributes | |
g = sns.FacetGrid(wines, col="wine_type", hue='quality_label', | |
col_order=['red', 'white'], hue_order=['low', 'medium', 'high'], | |
aspect=1.2, size=3.5, palette=sns.light_palette('navy', 4)[1:]) | |
g.map(plt.scatter, "volatile acidity", "alcohol", alpha=0.9, | |
edgecolor='white', linewidth=0.5, s=100) | |
fig = g.fig | |
fig.subplots_adjust(top=0.8, wspace=0.3) | |
fig.suptitle('Wine Type - Alcohol - Quality - Acidity', 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 4-D mix data using scatter plots | |
# leveraging the concepts of hue and facets for > 1 categorical attributes | |
g = sns.FacetGrid(wines, col="wine_type", hue='quality_label', | |
col_order=['red', 'white'], hue_order=['low', 'medium', 'high'], | |
aspect=1.2, size=3.5, palette=sns.light_palette('green', 4)[1:]) | |
g.map(plt.scatter, "volatile acidity", "total sulfur dioxide", alpha=0.9, | |
edgecolor='white', linewidth=0.5, s=100) | |
fig = g.fig | |
fig.subplots_adjust(top=0.8, wspace=0.3) | |
fig.suptitle('Wine Type - Sulfur Dioxide - Acidity - Quality', 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 5-D mix data using bubble charts | |
# leveraging the concepts of hue, size and depth | |
fig = plt.figure(figsize=(8, 6)) | |
ax = fig.add_subplot(111, projection='3d') | |
t = fig.suptitle('Wine Residual Sugar - Alcohol Content - Acidity - Total Sulfur Dioxide - Type', fontsize=14) | |
xs = list(wines['residual sugar']) | |
ys = list(wines['alcohol']) | |
zs = list(wines['fixed acidity']) | |
data_points = [(x, y, z) for x, y, z in zip(xs, ys, zs)] |