3D Scatter
Wine Quality Chemical Analysis
Wine dataset analysis showing chemical properties by wine type with quality-based sizing.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(444)
# Wine chemical properties
n_wines = 150
alcohol = np.random.uniform(8, 15, n_wines)
acidity = np.random.uniform(0.2, 1.0, n_wines)
sugar = np.random.exponential(5, n_wines) + 1
# Quality score (higher alcohol, moderate acidity = better)
quality = 5 + alcohol * 0.3 - np.abs(acidity - 0.5) * 2 + np.random.normal(0, 0.5, n_wines)
quality = np.clip(quality, 3, 9)
# Wine type
wine_type = np.random.choice(['Red', 'White', 'Rosé'], n_wines)
type_colors = {'Red': '#F5276C', 'White': '#F5B027', 'Rosé': '#F527B0'}
colors = [type_colors[t] for t in wine_type]
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
scatter = ax.scatter(alcohol, acidity, sugar, c=colors, s=quality*8,
alpha=0.7, edgecolors='#374151', linewidths=0.3)
ax.set_xlabel('Alcohol (%)', color='#1f2937', fontsize=10)
ax.set_ylabel('Volatile Acidity', color='#1f2937', fontsize=10)
ax.set_zlabel('Residual Sugar (g/L)', color='#1f2937', fontsize=10)
ax.set_title('Wine Quality Chemical Analysis', color='#1f2937', fontsize=14, fontweight='bold', pad=20)
ax.tick_params(colors='#6b7280', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#e5e7eb')
ax.yaxis.pane.set_edgecolor('#e5e7eb')
ax.zaxis.pane.set_edgecolor('#e5e7eb')
ax.view_init(elev=20, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
☕