Correlogram

Metabolic Health Correlogram

Clinical correlogram of metabolic markers by diagnosis status

Output
Metabolic Health Correlogram
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

np.random.seed(321)

n = 170
status = np.random.choice(['Normal', 'Prediabetic', 'Diabetic'], n)
data = {
    'Glucose': np.where(status == 'Normal', np.random.normal(90, 10, n),
                       np.where(status == 'Prediabetic', np.random.normal(115, 12, n), np.random.normal(150, 25, n))),
    'BMI': np.where(status == 'Normal', np.random.normal(23, 3, n),
                   np.where(status == 'Prediabetic', np.random.normal(28, 4, n), np.random.normal(32, 5, n))),
    'HbA1c (%)': np.where(status == 'Normal', np.random.normal(5.2, 0.3, n),
                         np.where(status == 'Prediabetic', np.random.normal(6, 0.3, n), np.random.normal(7.5, 1, n))),
    'Insulin': np.where(status == 'Normal', np.random.normal(8, 3, n),
                       np.where(status == 'Prediabetic', np.random.normal(15, 5, n), np.random.normal(25, 10, n))),
    'Status': status
}
df = pd.DataFrame(data)

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

palette = {'Normal': '#6CF527', 'Prediabetic': '#F5B027', 'Diabetic': '#F5276C'}

g = sns.pairplot(
    df,
    hue='Status',
    palette=palette,
    height=2,
    kind='reg',
    diag_kind='kde',
    markers=['o', 's', 'D'],
    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('Metabolic Health Indicators', 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