Skip to content

Instantly share code, notes, and snippets.

@dipanjanS
Created January 10, 2018 21:05
Show Gist options
  • Save dipanjanS/4a4569e0819098e9f2323f5db700b012 to your computer and use it in GitHub Desktop.
Save dipanjanS/4a4569e0819098e9f2323f5db700b012 to your computer and use it in GitHub Desktop.
# 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)]
colors = ['red' if wt == 'red' else 'yellow' for wt in list(wines['wine_type'])]
for data, color in zip(data_points, colors):
x, y, z = data
ax.scatter(x, y, z, alpha=0.4, c=color, edgecolors='none', s=30)
ax.set_xlabel('Residual Sugar')
ax.set_ylabel('Alcohol')
ax.set_zlabel('Fixed Acidity')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment