Correlogram

Coffee Origin Quality Matrix

Agricultural correlogram of coffee attributes by origin

Output
Coffee Origin Quality Matrix
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

np.random.seed(111)

n = 150
origin = np.random.choice(['Ethiopian', 'Colombian', 'Brazilian'], n)
data = {
    'Aroma': np.where(origin == 'Ethiopian', np.random.normal(8.5, 0.5, n),
                     np.where(origin == 'Colombian', np.random.normal(8, 0.6, n), np.random.normal(7.5, 0.5, n))),
    'Acidity': np.where(origin == 'Ethiopian', np.random.normal(8.2, 0.6, n),
                       np.where(origin == 'Colombian', np.random.normal(7.5, 0.5, n), np.random.normal(6.8, 0.6, n))),
    'Body': np.where(origin == 'Brazilian', np.random.normal(8, 0.5, n),
                    np.where(origin == 'Colombian', np.random.normal(7.8, 0.4, n), np.random.normal(7.2, 0.5, n))),
    'Sweetness': np.random.normal(7.5, 0.6, n),
    'Origin': origin
}
df = pd.DataFrame(data)

sns.set_style("whitegrid", {'axes.facecolor': '#ffffff', 'figure.facecolor': '#ffffff', 'grid.color': '#eeeeee'})

palette = {'Ethiopian': '#9C2007', 'Colombian': '#F5B027', 'Brazilian': '#6CF527'}

g = sns.pairplot(
    df,
    hue='Origin',
    palette=palette,
    height=2,
    kind='reg',
    diag_kind='kde',
    markers=['o', 's', '^'],
    plot_kws={'scatter_kws': {'alpha': 0.65, 's': 50, 'edgecolor': 'white', 'linewidths': 0.6}, 'line_kws': {'linewidth': 2}},
    diag_kws={'alpha': 0.5, 'linewidth': 2.5, 'fill': True}
)

g.fig.set_facecolor('#ffffff')
for ax in g.axes.flat:
    if ax:
        ax.set_facecolor('#ffffff')
        for spine in ax.spines.values():
            spine.set_color('#dddddd')
        ax.tick_params(colors='#666666')
        ax.xaxis.label.set_color('#333333')
        ax.yaxis.label.set_color('#333333')

g.fig.suptitle('Specialty Coffee Cupping Scores', fontsize=14, fontweight='bold', color='#1a1a1a', y=1.02)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support