Correlogram

Drug Interaction Profiling

Pharmacokinetic parameter correlations by drug class

Output
Drug Interaction Profiling
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np

np.random.seed(111)

n = 150
drug_class = np.random.choice(['Antibiotic', 'Analgesic', 'Antiviral'], n)
data = {
    'Half-life (h)': np.where(drug_class == 'Antibiotic', np.random.normal(6, 2, n),
                             np.where(drug_class == 'Analgesic', np.random.normal(4, 1.5, n), np.random.normal(12, 4, n))),
    'Clearance': np.where(drug_class == 'Antibiotic', np.random.normal(8, 2, n),
                         np.where(drug_class == 'Analgesic', np.random.normal(12, 3, n), np.random.normal(5, 1.5, n))),
    'Bioavail (%)': np.random.normal(70, 15, n),
    'Vd (L/kg)': np.random.normal(0.5, 0.2, n),
    'Class': drug_class
}
df = pd.DataFrame(data)

plt.style.use('dark_background')
sns.set_style("darkgrid", {'axes.facecolor': '#0a0a0f', 'figure.facecolor': '#0a0a0f', 'grid.color': '#333333'})

palette = {'Antibiotic': '#4927F5', 'Analgesic': '#F5276C', 'Antiviral': '#6CF527'}

g = sns.pairplot(
    df,
    hue='Class',
    palette=palette,
    height=2,
    kind='scatter',
    diag_kind='hist',
    markers=['o', 's', '^'],
    plot_kws={'alpha': 0.7, 's': 55, 'edgecolor': 'white', 'linewidths': 0.5},
    diag_kws={'alpha': 0.6, 'edgecolor': 'white', 'linewidth': 0.5}
)

g.fig.set_facecolor('#0a0a0f')
for ax in g.axes.flat:
    if ax:
        ax.set_facecolor('#0a0a0f')
        for spine in ax.spines.values():
            spine.set_color('#333333')
        ax.tick_params(colors='#888888')
        ax.xaxis.label.set_color('white')
        ax.yaxis.label.set_color('white')

g.fig.suptitle('Pharmacokinetic Profiles', fontsize=14, fontweight='bold', color='white', y=1.02)
plt.setp(g._legend.get_title(), color='white')
plt.setp(g._legend.get_texts(), color='white')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support